1 module directx.dwrite; 2 //+-------------------------------------------------------------------------- 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // Abstract: 7 // DirectX Typography Services public API definitions. 8 // 9 //---------------------------------------------------------------------------- 10 11 version(Direct2D_1_3) 12 version = Direct2D_1_2; 13 version(Direct2D_1_2) 14 version = Direct2D_1_1; 15 version(Direct2D_1_1): 16 version = Direct2D_1_0; 17 18 version(Windows): 19 version(DirectWrite): 20 21 public import directx.com; 22 public import directx.dcommon; 23 24 /// <summary> 25 /// The type of a font represented by a single font file. 26 /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have 27 /// separate enum values for each of the file type. 28 /// </summary> 29 alias DWRITE_FONT_FILE_TYPE = int; 30 enum : DWRITE_FONT_FILE_TYPE 31 { 32 /// <summary> 33 /// Font type is not recognized by the DirectWrite font system. 34 /// </summary> 35 DWRITE_FONT_FILE_TYPE_UNKNOWN, 36 37 /// <summary> 38 /// OpenType font with CFF outlines. 39 /// </summary> 40 DWRITE_FONT_FILE_TYPE_CFF, 41 42 /// <summary> 43 /// OpenType font with TrueType outlines. 44 /// </summary> 45 DWRITE_FONT_FILE_TYPE_TRUETYPE, 46 47 /// <summary> 48 /// OpenType font that contains a TrueType collection. 49 /// </summary> 50 DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION, 51 52 /// <summary> 53 /// Type 1 PFM font. 54 /// </summary> 55 DWRITE_FONT_FILE_TYPE_TYPE1_PFM, 56 57 /// <summary> 58 /// Type 1 PFB font. 59 /// </summary> 60 DWRITE_FONT_FILE_TYPE_TYPE1_PFB, 61 62 /// <summary> 63 /// Vector .FON font. 64 /// </summary> 65 DWRITE_FONT_FILE_TYPE_VECTOR, 66 67 /// <summary> 68 /// Bitmap .FON font. 69 /// </summary> 70 DWRITE_FONT_FILE_TYPE_BITMAP 71 } 72 73 /// <summary> 74 /// The file format of a complete font face. 75 /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have 76 /// a single enum entry. 77 /// </summary> 78 alias DWRITE_FONT_FACE_TYPE = int; 79 enum : DWRITE_FONT_FACE_TYPE 80 { 81 /// <summary> 82 /// OpenType font face with CFF outlines. 83 /// </summary> 84 DWRITE_FONT_FACE_TYPE_CFF, 85 86 /// <summary> 87 /// OpenType font face with TrueType outlines. 88 /// </summary> 89 DWRITE_FONT_FACE_TYPE_TRUETYPE, 90 91 /// <summary> 92 /// OpenType font face that is a part of a TrueType collection. 93 /// </summary> 94 DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION, 95 96 /// <summary> 97 /// A Type 1 font face. 98 /// </summary> 99 DWRITE_FONT_FACE_TYPE_TYPE1, 100 101 /// <summary> 102 /// A vector .FON format font face. 103 /// </summary> 104 DWRITE_FONT_FACE_TYPE_VECTOR, 105 106 /// <summary> 107 /// A bitmap .FON format font face. 108 /// </summary> 109 DWRITE_FONT_FACE_TYPE_BITMAP, 110 111 /// <summary> 112 /// Font face type is not recognized by the DirectWrite font system. 113 /// </summary> 114 DWRITE_FONT_FACE_TYPE_UNKNOWN, 115 116 /// <summary> 117 /// The font data includes only the CFF table from an OpenType CFF font. 118 /// This font face type can be used only for embedded fonts (i.e., custom 119 /// font file loaders) and the resulting font face object supports only the 120 /// minimum functionality necessary to render glyphs. 121 /// </summary> 122 DWRITE_FONT_FACE_TYPE_RAW_CFF 123 } 124 125 /// <summary> 126 /// Specifies algorithmic style simulations to be applied to the font face. 127 /// Bold and oblique simulations can be combined via bitwise OR operation. 128 /// </summary> 129 alias DWRITE_FONT_SIMULATIONS = int; 130 enum : DWRITE_FONT_SIMULATIONS 131 { 132 /// <summary> 133 /// No simulations are performed. 134 /// </summary> 135 DWRITE_FONT_SIMULATIONS_NONE = 0x0000, 136 137 /// <summary> 138 /// Algorithmic emboldening is performed. 139 /// </summary> 140 DWRITE_FONT_SIMULATIONS_BOLD = 0x0001, 141 142 /// <summary> 143 /// Algorithmic italicization is performed. 144 /// </summary> 145 DWRITE_FONT_SIMULATIONS_OBLIQUE = 0x0002 146 }; 147 148 /* 149 #ifdef DEFINE_ENUM_FLAG_OPERATORS 150 DEFINE_ENUM_FLAG_OPERATORS(DWRITE_FONT_SIMULATIONS); 151 #endif 152 */ 153 154 /// <summary> 155 /// The font weight enumeration describes common values for degree of blackness or thickness of strokes of characters in a font. 156 /// Font weight values less than 1 or greater than 999 are considered to be invalid, and they are rejected by font API functions. 157 /// </summary> 158 alias DWRITE_FONT_WEIGHT = int; 159 enum : DWRITE_FONT_WEIGHT 160 { 161 /// <summary> 162 /// Predefined font weight : Thin (100). 163 /// </summary> 164 DWRITE_FONT_WEIGHT_THIN = 100, 165 166 /// <summary> 167 /// Predefined font weight : Extra-light (200). 168 /// </summary> 169 DWRITE_FONT_WEIGHT_EXTRA_LIGHT = 200, 170 171 /// <summary> 172 /// Predefined font weight : Ultra-light (200). 173 /// </summary> 174 DWRITE_FONT_WEIGHT_ULTRA_LIGHT = 200, 175 176 /// <summary> 177 /// Predefined font weight : Light (300). 178 /// </summary> 179 DWRITE_FONT_WEIGHT_LIGHT = 300, 180 181 /// <summary> 182 /// Predefined font weight : Semi-light (350). 183 /// </summary> 184 DWRITE_FONT_WEIGHT_SEMI_LIGHT = 350, 185 186 /// <summary> 187 /// Predefined font weight : Normal (400). 188 /// </summary> 189 DWRITE_FONT_WEIGHT_NORMAL = 400, 190 191 /// <summary> 192 /// Predefined font weight : Regular (400). 193 /// </summary> 194 DWRITE_FONT_WEIGHT_REGULAR = 400, 195 196 /// <summary> 197 /// Predefined font weight : Medium (500). 198 /// </summary> 199 DWRITE_FONT_WEIGHT_MEDIUM = 500, 200 201 /// <summary> 202 /// Predefined font weight : Demi-bold (600). 203 /// </summary> 204 DWRITE_FONT_WEIGHT_DEMI_BOLD = 600, 205 206 /// <summary> 207 /// Predefined font weight : Semi-bold (600). 208 /// </summary> 209 DWRITE_FONT_WEIGHT_SEMI_BOLD = 600, 210 211 /// <summary> 212 /// Predefined font weight : Bold (700). 213 /// </summary> 214 DWRITE_FONT_WEIGHT_BOLD = 700, 215 216 /// <summary> 217 /// Predefined font weight : Extra-bold (800). 218 /// </summary> 219 DWRITE_FONT_WEIGHT_EXTRA_BOLD = 800, 220 221 /// <summary> 222 /// Predefined font weight : Ultra-bold (800). 223 /// </summary> 224 DWRITE_FONT_WEIGHT_ULTRA_BOLD = 800, 225 226 /// <summary> 227 /// Predefined font weight : Black (900). 228 /// </summary> 229 DWRITE_FONT_WEIGHT_BLACK = 900, 230 231 /// <summary> 232 /// Predefined font weight : Heavy (900). 233 /// </summary> 234 DWRITE_FONT_WEIGHT_HEAVY = 900, 235 236 /// <summary> 237 /// Predefined font weight : Extra-black (950). 238 /// </summary> 239 DWRITE_FONT_WEIGHT_EXTRA_BLACK = 950, 240 241 /// <summary> 242 /// Predefined font weight : Ultra-black (950). 243 /// </summary> 244 DWRITE_FONT_WEIGHT_ULTRA_BLACK = 950 245 } 246 247 /// <summary> 248 /// The font stretch enumeration describes relative change from the normal aspect ratio 249 /// as specified by a font designer for the glyphs in a font. 250 /// Values less than 1 or greater than 9 are considered to be invalid, and they are rejected by font API functions. 251 /// </summary> 252 alias DWRITE_FONT_STRETCH = int; 253 enum : DWRITE_FONT_STRETCH 254 { 255 /// <summary> 256 /// Predefined font stretch : Not known (0). 257 /// </summary> 258 DWRITE_FONT_STRETCH_UNDEFINED = 0, 259 260 /// <summary> 261 /// Predefined font stretch : Ultra-condensed (1). 262 /// </summary> 263 DWRITE_FONT_STRETCH_ULTRA_CONDENSED = 1, 264 265 /// <summary> 266 /// Predefined font stretch : Extra-condensed (2). 267 /// </summary> 268 DWRITE_FONT_STRETCH_EXTRA_CONDENSED = 2, 269 270 /// <summary> 271 /// Predefined font stretch : Condensed (3). 272 /// </summary> 273 DWRITE_FONT_STRETCH_CONDENSED = 3, 274 275 /// <summary> 276 /// Predefined font stretch : Semi-condensed (4). 277 /// </summary> 278 DWRITE_FONT_STRETCH_SEMI_CONDENSED = 4, 279 280 /// <summary> 281 /// Predefined font stretch : Normal (5). 282 /// </summary> 283 DWRITE_FONT_STRETCH_NORMAL = 5, 284 285 /// <summary> 286 /// Predefined font stretch : Medium (5). 287 /// </summary> 288 DWRITE_FONT_STRETCH_MEDIUM = 5, 289 290 /// <summary> 291 /// Predefined font stretch : Semi-expanded (6). 292 /// </summary> 293 DWRITE_FONT_STRETCH_SEMI_EXPANDED = 6, 294 295 /// <summary> 296 /// Predefined font stretch : Expanded (7). 297 /// </summary> 298 DWRITE_FONT_STRETCH_EXPANDED = 7, 299 300 /// <summary> 301 /// Predefined font stretch : Extra-expanded (8). 302 /// </summary> 303 DWRITE_FONT_STRETCH_EXTRA_EXPANDED = 8, 304 305 /// <summary> 306 /// Predefined font stretch : Ultra-expanded (9). 307 /// </summary> 308 DWRITE_FONT_STRETCH_ULTRA_EXPANDED = 9 309 } 310 311 /// <summary> 312 /// The font style enumeration describes the slope style of a font face, such as Normal, Italic or Oblique. 313 /// Values other than the ones defined in the enumeration are considered to be invalid, and they are rejected by font API functions. 314 /// </summary> 315 alias DWRITE_FONT_STYLE = int; 316 enum : DWRITE_FONT_STYLE 317 { 318 /// <summary> 319 /// Font slope style : Normal. 320 /// </summary> 321 DWRITE_FONT_STYLE_NORMAL, 322 323 /// <summary> 324 /// Font slope style : Oblique. 325 /// </summary> 326 DWRITE_FONT_STYLE_OBLIQUE, 327 328 /// <summary> 329 /// Font slope style : Italic. 330 /// </summary> 331 DWRITE_FONT_STYLE_ITALIC 332 333 } 334 335 /// <summary> 336 /// The informational string enumeration identifies a string in a font. 337 /// </summary> 338 alias DWRITE_INFORMATIONAL_STRING_ID = int; 339 enum : DWRITE_INFORMATIONAL_STRING_ID 340 { 341 /// <summary> 342 /// Unspecified name ID. 343 /// </summary> 344 DWRITE_INFORMATIONAL_STRING_NONE, 345 346 /// <summary> 347 /// Copyright notice provided by the font. 348 /// </summary> 349 DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, 350 351 /// <summary> 352 /// String containing a version number. 353 /// </summary> 354 DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, 355 356 /// <summary> 357 /// Trademark information provided by the font. 358 /// </summary> 359 DWRITE_INFORMATIONAL_STRING_TRADEMARK, 360 361 /// <summary> 362 /// Name of the font manufacturer. 363 /// </summary> 364 DWRITE_INFORMATIONAL_STRING_MANUFACTURER, 365 366 /// <summary> 367 /// Name of the font designer. 368 /// </summary> 369 DWRITE_INFORMATIONAL_STRING_DESIGNER, 370 371 /// <summary> 372 /// URL of font designer (with protocol, e.g., http://, ftp://). 373 /// </summary> 374 DWRITE_INFORMATIONAL_STRING_DESIGNER_URL, 375 376 /// <summary> 377 /// Description of the font. Can contain revision information, usage recommendations, history, features, etc. 378 /// </summary> 379 DWRITE_INFORMATIONAL_STRING_DESCRIPTION, 380 381 /// <summary> 382 /// URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font. 383 /// </summary> 384 DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL, 385 386 /// <summary> 387 /// Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese. 388 /// </summary> 389 DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION, 390 391 /// <summary> 392 /// URL where additional licensing information can be found. 393 /// </summary> 394 DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL, 395 396 /// <summary> 397 /// GDI-compatible family name. Because GDI allows a maximum of four fonts per family, fonts in the same family may have different GDI-compatible family names 398 /// (e.g., "Arial", "Arial Narrow", "Arial Black"). 399 /// </summary> 400 DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, 401 402 /// <summary> 403 /// GDI-compatible subfamily name. 404 /// </summary> 405 DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES, 406 407 /// <summary> 408 /// Family name preferred by the designer. This enables font designers to group more than four fonts in a single family without losing compatibility with 409 /// GDI. This name is typically only present if it differs from the GDI-compatible family name. 410 /// </summary> 411 DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES, 412 413 /// <summary> 414 /// Subfamily name preferred by the designer. This name is typically only present if it differs from the GDI-compatible subfamily name. 415 /// </summary> 416 DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES, 417 418 /// <summary> 419 /// Sample text. This can be the font name or any other text that the designer thinks is the best example to display the font in. 420 /// </summary> 421 DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT, 422 423 /// <summary> 424 /// The full name of the font, e.g. "Arial Bold", from name id 4 in the name table. 425 /// </summary> 426 DWRITE_INFORMATIONAL_STRING_FULL_NAME, 427 428 /// <summary> 429 /// The postscript name of the font, e.g. "GillSans-Bold" from name id 6 in the name table. 430 /// </summary> 431 DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME, 432 433 /// <summary> 434 /// The postscript CID findfont name, from name id 20 in the name table. 435 /// </summary> 436 DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME 437 } 438 439 440 /// <summary> 441 /// The DWRITE_FONT_METRICS structure specifies the metrics of a font face that 442 /// are applicable to all glyphs within the font face. 443 /// </summary> 444 struct DWRITE_FONT_METRICS 445 { 446 /// <summary> 447 /// The number of font design units per em unit. 448 /// Font files use their own coordinate system of font design units. 449 /// A font design unit is the smallest measurable unit in the em square, 450 /// an imaginary square that is used to size and align glyphs. 451 /// The concept of em square is used as a reference scale factor when defining font size and device transformation semantics. 452 /// The size of one em square is also commonly used to compute the paragraph indentation value. 453 /// </summary> 454 UINT16 designUnitsPerEm; 455 456 /// <summary> 457 /// Ascent value of the font face in font design units. 458 /// Ascent is the distance from the top of font character alignment box to English baseline. 459 /// </summary> 460 UINT16 ascent; 461 462 /// <summary> 463 /// Descent value of the font face in font design units. 464 /// Descent is the distance from the bottom of font character alignment box to English baseline. 465 /// </summary> 466 UINT16 descent; 467 468 /// <summary> 469 /// Line gap in font design units. 470 /// Recommended additional white space to add between lines to improve legibility. The recommended line spacing 471 /// (baseline-to-baseline distance) is thus the sum of ascent, descent, and lineGap. The line gap is usually 472 /// positive or zero but can be negative, in which case the recommended line spacing is less than the height 473 /// of the character alignment box. 474 /// </summary> 475 INT16 lineGap; 476 477 /// <summary> 478 /// Cap height value of the font face in font design units. 479 /// Cap height is the distance from English baseline to the top of a typical English capital. 480 /// Capital "H" is often used as a reference character for the purpose of calculating the cap height value. 481 /// </summary> 482 UINT16 capHeight; 483 484 /// <summary> 485 /// x-height value of the font face in font design units. 486 /// x-height is the distance from English baseline to the top of lowercase letter "x", or a similar lowercase character. 487 /// </summary> 488 UINT16 xHeight; 489 490 /// <summary> 491 /// The underline position value of the font face in font design units. 492 /// Underline position is the position of underline relative to the English baseline. 493 /// The value is usually made negative in order to place the underline below the baseline. 494 /// </summary> 495 INT16 underlinePosition; 496 497 /// <summary> 498 /// The suggested underline thickness value of the font face in font design units. 499 /// </summary> 500 UINT16 underlineThickness; 501 502 /// <summary> 503 /// The strikethrough position value of the font face in font design units. 504 /// Strikethrough position is the position of strikethrough relative to the English baseline. 505 /// The value is usually made positive in order to place the strikethrough above the baseline. 506 /// </summary> 507 INT16 strikethroughPosition; 508 509 /// <summary> 510 /// The suggested strikethrough thickness value of the font face in font design units. 511 /// </summary> 512 UINT16 strikethroughThickness; 513 } 514 515 /// <summary> 516 /// The DWRITE_GLYPH_METRICS structure specifies the metrics of an individual glyph. 517 /// The units depend on how the metrics are obtained. 518 /// </summary> 519 struct DWRITE_GLYPH_METRICS 520 { 521 /// <summary> 522 /// Specifies the X offset from the glyph origin to the left edge of the black box. 523 /// The glyph origin is the current horizontal writing position. 524 /// A negative value means the black box extends to the left of the origin (often true for lowercase italic 'f'). 525 /// </summary> 526 INT32 leftSideBearing; 527 528 /// <summary> 529 /// Specifies the X offset from the origin of the current glyph to the origin of the next glyph when writing horizontally. 530 /// </summary> 531 UINT32 advanceWidth; 532 533 /// <summary> 534 /// Specifies the X offset from the right edge of the black box to the origin of the next glyph when writing horizontally. 535 /// The value is negative when the right edge of the black box overhangs the layout box. 536 /// </summary> 537 INT32 rightSideBearing; 538 539 /// <summary> 540 /// Specifies the vertical offset from the vertical origin to the top of the black box. 541 /// Thus, a positive value adds whitespace whereas a negative value means the glyph overhangs the top of the layout box. 542 /// </summary> 543 INT32 topSideBearing; 544 545 /// <summary> 546 /// Specifies the Y offset from the vertical origin of the current glyph to the vertical origin of the next glyph when writing vertically. 547 /// (Note that the term "origin" by itself denotes the horizontal origin. The vertical origin is different. 548 /// Its Y coordinate is specified by verticalOriginY value, 549 /// and its X coordinate is half the advanceWidth to the right of the horizontal origin). 550 /// </summary> 551 UINT32 advanceHeight; 552 553 /// <summary> 554 /// Specifies the vertical distance from the black box's bottom edge to the advance height. 555 /// Positive when the bottom edge of the black box is within the layout box. 556 /// Negative when the bottom edge of black box overhangs the layout box. 557 /// </summary> 558 INT32 bottomSideBearing; 559 560 /// <summary> 561 /// Specifies the Y coordinate of a glyph's vertical origin, in the font's design coordinate system. 562 /// The y coordinate of a glyph's vertical origin is the sum of the glyph's top side bearing 563 /// and the top (i.e. yMax) of the glyph's bounding box. 564 /// </summary> 565 INT32 verticalOriginY; 566 } 567 568 /// <summary> 569 /// Optional adjustment to a glyph's position. A glyph offset changes the position of a glyph without affecting 570 /// the pen position. Offsets are in logical, pre-transform units. 571 /// </summary> 572 struct DWRITE_GLYPH_OFFSET 573 { 574 /// <summary> 575 /// Offset in the advance direction of the run. A positive advance offset moves the glyph to the right 576 /// (in pre-transform coordinates) if the run is left-to-right or to the left if the run is right-to-left. 577 /// </summary> 578 FLOAT advanceOffset; 579 580 /// <summary> 581 /// Offset in the ascent direction, i.e., the direction ascenders point. A positive ascender offset moves 582 /// the glyph up (in pre-transform coordinates). 583 /// </summary> 584 FLOAT ascenderOffset; 585 } 586 587 /// <summary> 588 /// Specifies the type of DirectWrite factory object. 589 /// DirectWrite factory contains internal state such as font loader registration and cached font data. 590 /// In most cases it is recommended to use the shared factory object, because it allows multiple components 591 /// that use DirectWrite to share internal DirectWrite state and reduce memory usage. 592 /// However, there are cases when it is desirable to reduce the impact of a component, 593 /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it 594 /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed 595 /// component. 596 /// </summary> 597 alias DWRITE_FACTORY_TYPE = int; 598 enum : DWRITE_FACTORY_TYPE 599 { 600 /// <summary> 601 /// Shared factory allow for re-use of cached font data across multiple in process components. 602 /// Such factories also take advantage of cross process font caching components for better performance. 603 /// </summary> 604 DWRITE_FACTORY_TYPE_SHARED, 605 606 /// <summary> 607 /// Objects created from the isolated factory do not interact with internal DirectWrite state from other components. 608 /// </summary> 609 DWRITE_FACTORY_TYPE_ISOLATED 610 } 611 612 // Creates an OpenType tag as a 32bit integer such that 613 // the first character in the tag is the lowest byte, 614 // (least significant on little endian architectures) 615 // which can be used to compare with tags in the font file. 616 // This macro is compatible with DWRITE_FONT_FEATURE_TAG. 617 // 618 // Example: DWRITE_MAKE_OPENTYPE_TAG('c','c','m','p') 619 // Dword: 0x706D6363 620 // 621 UINT32 DWRITE_MAKE_OPENTYPE_TAG(alias a, alias b, alias c, alias d)() 622 { 623 return 624 (cast(UINT32)(cast(UINT8)d << 24)) | 625 (cast(UINT32)(cast(UINT8)c << 16)) | 626 (cast(UINT32)(cast(UINT8)b << 8 )) | 627 (cast(UINT32)(cast(UINT8)a )); 628 } 629 630 /// <summary> 631 /// Font file loader interface handles loading font file resources of a particular type from a key. 632 /// The font file loader interface is recommended to be implemented by a singleton object. 633 /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite factory 634 /// inside their constructors and must not unregister themselves in their destructors, because 635 /// registration and unregistration operations increment and decrement the object reference count respectively. 636 /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed 637 /// outside of the font file loader implementation as a separate step. 638 /// </summary> 639 mixin( uuid!(IDWriteFontFileLoader, "727cad4e-d6af-4c9e-8a08-d695b11caa49") ); 640 interface IDWriteFontFileLoader : IUnknown 641 { 642 extern(Windows): 643 /// <summary> 644 /// Creates a font file stream object that encapsulates an open file resource. 645 /// The resource is closed when the last reference to fontFileStream is released. 646 /// </summary> 647 /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource 648 /// within the scope of the font loader being used.</param> 649 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 650 /// <param name="fontFileStream">Pointer to the newly created font file stream.</param> 651 /// <returns> 652 /// Standard HRESULT error code. 653 /// </returns> 654 HRESULT CreateStreamFromKey( 655 const(void*) fontFileReferenceKey, 656 UINT32 fontFileReferenceKeySize, 657 /*out*/ IDWriteFontFileStream* fontFileStream 658 ); 659 } 660 661 /// <summary> 662 /// A built-in implementation of IDWriteFontFileLoader interface that operates on local font files 663 /// and exposes local font file information from the font file reference key. 664 /// Font file references created using CreateFontFileReference use this font file loader. 665 /// </summary> 666 mixin( uuid!(IDWriteLocalFontFileLoader, "b2d9f3ec-c9fe-4a11-a2ec-d86208f7c0a2") ); 667 interface IDWriteLocalFontFileLoader : IDWriteFontFileLoader 668 { 669 extern(Windows): 670 /// <summary> 671 /// Obtains the length of the absolute file path from the font file reference key. 672 /// </summary> 673 /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file 674 /// within the scope of the font loader being used.</param> 675 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 676 /// <param name="filePathLength">Length of the file path string not including the terminated NULL character.</param> 677 /// <returns> 678 /// Standard HRESULT error code. 679 /// </returns> 680 HRESULT GetFilePathLengthFromKey( 681 const(void*) fontFileReferenceKey, 682 UINT32 fontFileReferenceKeySize, 683 /*out*/ UINT32* filePathLength 684 ); 685 686 /// <summary> 687 /// Obtains the absolute font file path from the font file reference key. 688 /// </summary> 689 /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file 690 /// within the scope of the font loader being used.</param> 691 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 692 /// <param name="filePath">Character array that receives the local file path.</param> 693 /// <param name="filePathSize">Size of the filePath array in character count including the terminated NULL character.</param> 694 /// <returns> 695 /// Standard HRESULT error code. 696 /// </returns> 697 HRESULT GetFilePathFromKey( 698 const(void*) fontFileReferenceKey, 699 UINT32 fontFileReferenceKeySize, 700 /*out*/ WCHAR* filePath, 701 UINT32 filePathSize 702 ); 703 704 /// <summary> 705 /// Obtains the last write time of the file from the font file reference key. 706 /// </summary> 707 /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file 708 /// within the scope of the font loader being used.</param> 709 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 710 /// <param name="lastWriteTime">Last modified time of the font file.</param> 711 /// <returns> 712 /// Standard HRESULT error code. 713 /// </returns> 714 HRESULT GetLastWriteTimeFromKey( 715 const(void*) fontFileReferenceKey, 716 UINT32 fontFileReferenceKeySize, 717 /*out*/ FILETIME* lastWriteTime 718 ); 719 } 720 721 /// <summary> 722 /// The interface for loading font file data. 723 /// </summary> 724 mixin( uuid!(IDWriteFontFileStream, "6d4865fe-0ab8-4d91-8f62-5dd6be34a3e0") ); 725 interface IDWriteFontFileStream : IUnknown 726 { 727 extern(Windows): 728 /// <summary> 729 /// Reads a fragment from a file. 730 /// </summary> 731 /// <param name="fragmentStart">Receives the pointer to the start of the font file fragment.</param> 732 /// <param name="fileOffset">Offset of the fragment from the beginning of the font file.</param> 733 /// <param name="fragmentSize">Size of the fragment in bytes.</param> 734 /// <param name="fragmentContext">The client defined context to be passed to the ReleaseFileFragment.</param> 735 /// <returns> 736 /// Standard HRESULT error code. 737 /// </returns> 738 /// <remarks> 739 /// IMPORTANT: ReadFileFragment() implementations must check whether the requested file fragment 740 /// is within the file bounds. Otherwise, an error should be returned from ReadFileFragment. 741 /// </remarks> 742 HRESULT ReadFileFragment( 743 const(void**) fragmentStart, 744 UINT64 fileOffset, 745 UINT64 fragmentSize, 746 /*out*/void** fragmentContext 747 ); 748 749 /// <summary> 750 /// Releases a fragment from a file. 751 /// </summary> 752 /// <param name="fragmentContext">The client defined context of a font fragment returned from ReadFileFragment.</param> 753 void ReleaseFileFragment( 754 void* fragmentContext 755 ); 756 757 /// <summary> 758 /// Obtains the total size of a file. 759 /// </summary> 760 /// <param name="fileSize">Receives the total size of the file.</param> 761 /// <returns> 762 /// Standard HRESULT error code. 763 /// </returns> 764 /// <remarks> 765 /// Implementing GetFileSize() for asynchronously loaded font files may require 766 /// downloading the complete file contents, therefore this method should only be used for operations that 767 /// either require complete font file to be loaded (e.g., copying a font file) or need to make 768 /// decisions based on the value of the file size (e.g., validation against a persisted file size). 769 /// </remarks> 770 HRESULT GetFileSize( 771 /*out*/ UINT64* fileSize 772 ); 773 774 /// <summary> 775 /// Obtains the last modified time of the file. The last modified time is used by DirectWrite font selection algorithms 776 /// to determine whether one font resource is more up to date than another one. 777 /// </summary> 778 /// <param name="lastWriteTime">Receives the last modified time of the file in the format that represents 779 /// the number of 100-nanosecond intervals since January 1, 1601 (UTC).</param> 780 /// <returns> 781 /// Standard HRESULT error code. For resources that don't have a concept of the last modified time, the implementation of 782 /// GetLastWriteTime should return E_NOTIMPL. 783 /// </returns> 784 HRESULT GetLastWriteTime( 785 /*out*/ UINT64* lastWriteTime 786 ); 787 } 788 789 /// <summary> 790 /// The interface that represents a reference to a font file. 791 /// </summary> 792 mixin( uuid!(IDWriteFontFile, "739d886a-cef5-47dc-8769-1a8b41bebbb0") ); 793 interface IDWriteFontFile : IUnknown 794 { 795 extern(Windows): 796 /// <summary> 797 /// This method obtains the pointer to the reference key of a font file. The pointer is only valid until the object that refers to it is released. 798 /// </summary> 799 /// <param name="fontFileReferenceKey">Pointer to the font file reference key. 800 /// IMPORTANT: The pointer value is valid until the font file reference object it is obtained from is released.</param> 801 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 802 /// <returns> 803 /// Standard HRESULT error code. 804 /// </returns> 805 HRESULT GetReferenceKey( 806 const(void**) fontFileReferenceKey, 807 /*out*/ UINT32* fontFileReferenceKeySize 808 ); 809 810 /// <summary> 811 /// Obtains the file loader associated with a font file object. 812 /// </summary> 813 /// <param name="fontFileLoader">The font file loader associated with the font file object.</param> 814 /// <returns> 815 /// Standard HRESULT error code. 816 /// </returns> 817 HRESULT GetLoader( 818 /*out*/ IDWriteFontFileLoader* fontFileLoader 819 ); 820 821 /// <summary> 822 /// Analyzes a file and returns whether it represents a font, and whether the font type is supported by the font system. 823 /// </summary> 824 /// <param name="isSupportedFontType">TRUE if the font type is supported by the font system, FALSE otherwise.</param> 825 /// <param name="fontFileType">The type of the font file. Note that even if isSupportedFontType is FALSE, 826 /// the fontFileType value may be different from DWRITE_FONT_FILE_TYPE_UNKNOWN.</param> 827 /// <param name="fontFaceType">The type of the font face that can be constructed from the font file. 828 /// Note that even if isSupportedFontType is FALSE, the fontFaceType value may be different from 829 /// DWRITE_FONT_FACE_TYPE_UNKNOWN.</param> 830 /// <param name="numberOfFaces">Number of font faces contained in the font file.</param> 831 /// <returns> 832 /// Standard HRESULT error code if there was a processing error during analysis. 833 /// </returns> 834 /// <remarks> 835 /// IMPORTANT: certain font file types are recognized, but not supported by the font system. 836 /// For example, the font system will recognize a file as a Type 1 font file, 837 /// but will not be able to construct a font face object from it. In such situations, Analyze will set 838 /// isSupportedFontType output parameter to FALSE. 839 /// </remarks> 840 HRESULT Analyze( 841 /*out*/ BOOL* isSupportedFontType, 842 /*out*/ DWRITE_FONT_FILE_TYPE* fontFileType, 843 /*out*/ DWRITE_FONT_FACE_TYPE* fontFaceType, 844 /*out*/ UINT32* numberOfFaces 845 ); 846 } 847 848 /// <summary> 849 /// Represents the internal structure of a device pixel (i.e., the physical arrangement of red, 850 /// green, and blue color components) that is assumed for purposes of rendering text. 851 /// </summary> 852 alias DWRITE_PIXEL_GEOMETRY = int; 853 enum : DWRITE_PIXEL_GEOMETRY 854 { 855 /// <summary> 856 /// The red, green, and blue color components of each pixel are assumed to occupy the same point. 857 /// </summary> 858 DWRITE_PIXEL_GEOMETRY_FLAT, 859 860 /// <summary> 861 /// Each pixel comprises three vertical stripes, with red on the left, green in the center, and 862 /// blue on the right. This is the most common pixel geometry for LCD monitors. 863 /// </summary> 864 DWRITE_PIXEL_GEOMETRY_RGB, 865 866 /// <summary> 867 /// Each pixel comprises three vertical stripes, with blue on the left, green in the center, and 868 /// red on the right. 869 /// </summary> 870 DWRITE_PIXEL_GEOMETRY_BGR 871 } 872 873 /// <summary> 874 /// Represents a method of rendering glyphs. 875 /// </summary> 876 alias DWRITE_RENDERING_MODE = int; 877 enum : DWRITE_RENDERING_MODE 878 { 879 /// <summary> 880 /// Specifies that the rendering mode is determined automatically based on the font and size. 881 /// </summary> 882 DWRITE_RENDERING_MODE_DEFAULT, 883 884 /// <summary> 885 /// Specifies that no antialiasing is performed. Each pixel is either set to the foreground 886 /// color of the text or retains the color of the background. 887 /// </summary> 888 DWRITE_RENDERING_MODE_ALIASED, 889 890 /// <summary> 891 /// Specifies that antialiasing is performed in the horizontal direction and the appearance 892 /// of glyphs is layout-compatible with GDI using CLEARTYPE_QUALITY. Use DWRITE_MEASURING_MODE_GDI_CLASSIC 893 /// to get glyph advances. The antialiasing may be either ClearType or grayscale depending on 894 /// the text antialiasing mode. 895 /// </summary> 896 DWRITE_RENDERING_MODE_GDI_CLASSIC, 897 898 /// <summary> 899 /// Specifies that antialiasing is performed in the horizontal direction and the appearance 900 /// of glyphs is layout-compatible with GDI using CLEARTYPE_NATURAL_QUALITY. Glyph advances 901 /// are close to the font design advances, but are still rounded to whole pixels. Use 902 /// DWRITE_MEASURING_MODE_GDI_NATURAL to get glyph advances. The antialiasing may be either 903 /// ClearType or grayscale depending on the text antialiasing mode. 904 /// </summary> 905 DWRITE_RENDERING_MODE_GDI_NATURAL, 906 907 /// <summary> 908 /// Specifies that antialiasing is performed in the horizontal direction. This rendering 909 /// mode allows glyphs to be positioned with subpixel precision and is therefore suitable 910 /// for natural (i.e., resolution-independent) layout. The antialiasing may be either 911 /// ClearType or grayscale depending on the text antialiasing mode. 912 /// </summary> 913 DWRITE_RENDERING_MODE_NATURAL, 914 915 /// <summary> 916 /// Similar to natural mode except that antialiasing is performed in both the horizontal 917 /// and vertical directions. This is typically used at larger sizes to make curves and 918 /// diagonal lines look smoother. The antialiasing may be either ClearType or grayscale 919 /// depending on the text antialiasing mode. 920 /// </summary> 921 DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, 922 923 /// <summary> 924 /// Specifies that rendering should bypass the rasterizer and use the outlines directly. 925 /// This is typically used at very large sizes. 926 /// </summary> 927 DWRITE_RENDERING_MODE_OUTLINE, 928 929 // The following names are obsolete, but are kept as aliases to avoid breaking existing code. 930 // Each of these rendering modes may result in either ClearType or grayscale antialiasing 931 // depending on the DWRITE_TEXT_ANTIALIASING_MODE. 932 DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC = DWRITE_RENDERING_MODE_GDI_CLASSIC, 933 DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL = DWRITE_RENDERING_MODE_GDI_NATURAL, 934 DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL = DWRITE_RENDERING_MODE_NATURAL, 935 DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC 936 }; 937 938 /// <summary> 939 /// The DWRITE_MATRIX structure specifies the graphics transform to be applied 940 /// to rendered glyphs. 941 /// </summary> 942 struct DWRITE_MATRIX 943 { 944 /// <summary> 945 /// Horizontal scaling / cosine of rotation 946 /// </summary> 947 FLOAT m11; 948 949 /// <summary> 950 /// Vertical shear / sine of rotation 951 /// </summary> 952 FLOAT m12; 953 954 /// <summary> 955 /// Horizontal shear / negative sine of rotation 956 /// </summary> 957 FLOAT m21; 958 959 /// <summary> 960 /// Vertical scaling / cosine of rotation 961 /// </summary> 962 FLOAT m22; 963 964 /// <summary> 965 /// Horizontal shift (always orthogonal regardless of rotation) 966 /// </summary> 967 FLOAT dx; 968 969 /// <summary> 970 /// Vertical shift (always orthogonal regardless of rotation) 971 /// </summary> 972 FLOAT dy; 973 } 974 975 /// <summary> 976 /// The interface that represents text rendering settings for glyph rasterization and filtering. 977 /// </summary> 978 mixin( uuid!(IDWriteRenderingParams, "2f0da53a-2add-47cd-82ee-d9ec34688e75") ); 979 interface IDWriteRenderingParams : IUnknown 980 { 981 extern(Windows): 982 /// <summary> 983 /// Gets the gamma value used for gamma correction. Valid values must be 984 /// greater than zero and cannot exceed 256. 985 /// </summary> 986 FLOAT GetGamma(); 987 988 /// <summary> 989 /// Gets the amount of contrast enhancement. Valid values are greater than 990 /// or equal to zero. 991 /// </summary> 992 FLOAT GetEnhancedContrast(); 993 994 /// <summary> 995 /// Gets the ClearType level. Valid values range from 0.0f (no ClearType) 996 /// to 1.0f (full ClearType). 997 /// </summary> 998 FLOAT GetClearTypeLevel(); 999 1000 /// <summary> 1001 /// Gets the pixel geometry. 1002 /// </summary> 1003 DWRITE_PIXEL_GEOMETRY GetPixelGeometry(); 1004 1005 /// <summary> 1006 /// Gets the rendering mode. 1007 /// </summary> 1008 DWRITE_RENDERING_MODE GetRenderingMode(); 1009 } 1010 1011 // Forward declarations of D2D types 1012 //interface ID2D1SimplifiedGeometrySink; 1013 1014 version(Direct2D_1_0) 1015 { 1016 static import directx.d2d1; 1017 alias IDWriteGeometrySink = directx.d2d1.ID2D1SimplifiedGeometrySink; 1018 } 1019 1020 /// <summary> 1021 /// The interface that represents an absolute reference to a font face. 1022 /// It contains font face type, appropriate file references and face identification data. 1023 /// Various font data such as metrics, names and glyph outlines is obtained from IDWriteFontFace. 1024 /// </summary> 1025 mixin( uuid!(IDWriteFontFace, "5f49804d-7024-4d43-bfa9-d25984f53849") ); 1026 interface IDWriteFontFace : IUnknown 1027 { 1028 extern(Windows): 1029 /// <summary> 1030 /// Obtains the file format type of a font face. 1031 /// </summary> 1032 DWRITE_FONT_FACE_TYPE GetType(); 1033 1034 /// <summary> 1035 /// Obtains the font files representing a font face. 1036 /// </summary> 1037 /// <param name="numberOfFiles">The number of files representing the font face.</param> 1038 /// <param name="fontFiles">User provided array that stores pointers to font files representing the font face. 1039 /// This parameter can be NULL if the user is only interested in the number of files representing the font face. 1040 /// This API increments reference count of the font file pointers returned according to COM conventions, and the client 1041 /// should release them when finished.</param> 1042 /// <returns> 1043 /// Standard HRESULT error code. 1044 /// </returns> 1045 HRESULT GetFiles( 1046 /*inout*/ UINT32* numberOfFiles, 1047 /*out*/ IDWriteFontFile* fontFiles 1048 ); 1049 1050 /// <summary> 1051 /// Obtains the zero-based index of the font face in its font file or files. If the font files contain a single face, 1052 /// the return value is zero. 1053 /// </summary> 1054 UINT32 GetIndex(); 1055 1056 /// <summary> 1057 /// Obtains the algorithmic style simulation flags of a font face. 1058 /// </summary> 1059 DWRITE_FONT_SIMULATIONS GetSimulations(); 1060 1061 /// <summary> 1062 /// Determines whether the font is a symbol font. 1063 /// </summary> 1064 BOOL IsSymbolFont(); 1065 1066 /// <summary> 1067 /// Obtains design units and common metrics for the font face. 1068 /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations. 1069 /// </summary> 1070 /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in. 1071 /// The metrics returned by this function are in font design units.</param> 1072 void GetMetrics( 1073 /*out*/ DWRITE_FONT_METRICS* fontFaceMetrics 1074 ); 1075 1076 /// <summary> 1077 /// Obtains the number of glyphs in the font face. 1078 /// </summary> 1079 UINT16 GetGlyphCount(); 1080 1081 /// <summary> 1082 /// Obtains ideal glyph metrics in font design units. Design glyphs metrics are used for glyph positioning. 1083 /// </summary> 1084 /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param> 1085 /// <param name="glyphCount">The number of elements in the glyphIndices array.</param> 1086 /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function. 1087 /// The metrics returned by this function are in font design units.</param> 1088 /// <param name="isSideways">Indicates whether the font is being used in a sideways run. 1089 /// This can affect the glyph metrics if the font has oblique simulation 1090 /// because sideways oblique simulation differs from non-sideways oblique simulation.</param> 1091 /// <returns> 1092 /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range 1093 /// for the current font face, E_INVALIDARG will be returned. 1094 /// </returns> 1095 HRESULT GetDesignGlyphMetrics( 1096 const(UINT16)* glyphIndices, 1097 UINT32 glyphCount, 1098 /*out*/ DWRITE_GLYPH_METRICS* glyphMetrics, 1099 BOOL isSideways = FALSE 1100 ); 1101 1102 /// <summary> 1103 /// Returns the nominal mapping of UTF-32 Unicode code points to glyph indices as defined by the font 'cmap' table. 1104 /// Note that this mapping is primarily provided for line layout engines built on top of the physical font API. 1105 /// Because of OpenType glyph substitution and line layout character substitution, the nominal conversion does not always correspond 1106 /// to how a Unicode string will map to glyph indices when rendering using a particular font face. 1107 /// Also, note that Unicode Variation Selectors provide for alternate mappings for character to glyph. 1108 /// This call will always return the default variant. 1109 /// </summary> 1110 /// <param name="codePoints">An array of UTF-32 code points to obtain nominal glyph indices from.</param> 1111 /// <param name="codePointCount">The number of elements in the codePoints array.</param> 1112 /// <param name="glyphIndices">Array of nominal glyph indices filled by this function.</param> 1113 /// <returns> 1114 /// Standard HRESULT error code. 1115 /// </returns> 1116 HRESULT GetGlyphIndices( 1117 const(UINT32)* codePoints, 1118 UINT32 codePointCount, 1119 /*out*/ UINT16* glyphIndices 1120 ); 1121 1122 /// <summary> 1123 /// Finds the specified OpenType font table if it exists and returns a pointer to it. 1124 /// The function accesses the underlying font data via the IDWriteFontFileStream interface 1125 /// implemented by the font file loader. 1126 /// </summary> 1127 /// <param name="openTypeTableTag">Four character tag of table to find. 1128 /// Use the DWRITE_MAKE_OPENTYPE_TAG() macro to create it. 1129 /// Unlike GDI, it does not support the special TTCF and null tags to access the whole font.</param> 1130 /// <param name="tableData"> 1131 /// Pointer to base of table in memory. 1132 /// The pointer is only valid so long as the FontFace used to get the font table still exists 1133 /// (not any other FontFace, even if it actually refers to the same physical font). 1134 /// </param> 1135 /// <param name="tableSize">Byte size of table.</param> 1136 /// <param name="tableContext"> 1137 /// Opaque context which must be freed by calling ReleaseFontTable. 1138 /// The context actually comes from the lower level IDWriteFontFileStream, 1139 /// which may be implemented by the application or DWrite itself. 1140 /// It is possible for a NULL tableContext to be returned, especially if 1141 /// the implementation directly memory maps the whole file. 1142 /// Nevertheless, always release it later, and do not use it as a test for function success. 1143 /// The same table can be queried multiple times, 1144 /// but each returned context can be different, so release each separately. 1145 /// </param> 1146 /// <param name="exists">True if table exists.</param> 1147 /// <returns> 1148 /// Standard HRESULT error code. 1149 /// If a table can not be found, the function will not return an error, but the size will be 0, table NULL, and exists = FALSE. 1150 /// The context does not need to be freed if the table was not found. 1151 /// </returns> 1152 /// <remarks> 1153 /// The context for the same tag may be different for each call, 1154 /// so each one must be held and released separately. 1155 /// </remarks> 1156 HRESULT TryGetFontTable( 1157 UINT32 openTypeTableTag, 1158 const(void**) tableData, 1159 /*out*/ UINT32* tableSize, 1160 /*out*/ void** tableContext, 1161 /*out*/ BOOL* exists 1162 ); 1163 1164 /// <summary> 1165 /// Releases the table obtained earlier from TryGetFontTable. 1166 /// </summary> 1167 /// <param name="tableContext">Opaque context from TryGetFontTable.</param> 1168 void ReleaseFontTable( 1169 void* tableContext 1170 ); 1171 1172 /// <summary> 1173 /// Computes the outline of a run of glyphs by calling back to the outline sink interface. 1174 /// </summary> 1175 /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param> 1176 /// <param name="glyphIndices">Array of glyph indices.</param> 1177 /// <param name="glyphAdvances">Optional array of glyph advances in DIPs.</param> 1178 /// <param name="glyphOffsets">Optional array of glyph offsets.</param> 1179 /// <param name="glyphCount">Number of glyphs.</param> 1180 /// <param name="isSideways">If true, specifies that glyphs are rotated 90 degrees to the left and vertical metrics are used. 1181 /// A client can render a vertical run by specifying isSideways = true and rotating the resulting geometry 90 degrees to the 1182 /// right using a transform.</param> 1183 /// <param name="isRightToLeft">If true, specifies that the advance direction is right to left. By default, the advance direction 1184 /// is left to right.</param> 1185 /// <param name="geometrySink">Interface the function calls back to draw each element of the geometry.</param> 1186 /// <returns> 1187 /// Standard HRESULT error code. 1188 /// </returns> 1189 HRESULT GetGlyphRunOutline( 1190 FLOAT emSize, 1191 const(UINT16)* glyphIndices, 1192 const(FLOAT)* glyphAdvances, 1193 const(DWRITE_GLYPH_OFFSET)* glyphOffsets, 1194 UINT32 glyphCount, 1195 BOOL isSideways, 1196 BOOL isRightToLeft, 1197 IDWriteGeometrySink geometrySink 1198 ); 1199 1200 /// <summary> 1201 /// Determines the recommended rendering mode for the font given the specified size and rendering parameters. 1202 /// </summary> 1203 /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param> 1204 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this 1205 /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param> 1206 /// <param name="measuringMode">Specifies measuring mode that will be used for glyphs in the font. 1207 /// Renderer implementations may choose different rendering modes for given measuring modes, but 1208 /// best results are seen when the corresponding modes match: 1209 /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL 1210 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC 1211 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL 1212 /// </param> 1213 /// <param name="renderingParams">Rendering parameters object. This parameter is necessary in case the rendering parameters 1214 /// object overrides the rendering mode.</param> 1215 /// <param name="renderingMode">Receives the recommended rendering mode to use.</param> 1216 /// <returns> 1217 /// Standard HRESULT error code. 1218 /// </returns> 1219 HRESULT GetRecommendedRenderingMode( 1220 FLOAT emSize, 1221 FLOAT pixelsPerDip, 1222 DWRITE_MEASURING_MODE measuringMode, 1223 IDWriteRenderingParams renderingParams, 1224 /*out*/ DWRITE_RENDERING_MODE* renderingMode 1225 ); 1226 1227 /// <summary> 1228 /// Obtains design units and common metrics for the font face. 1229 /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations. 1230 /// </summary> 1231 /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param> 1232 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this 1233 /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param> 1234 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 1235 /// scaling specified by the font size and pixelsPerDip.</param> 1236 /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in. 1237 /// The metrics returned by this function are in font design units.</param> 1238 HRESULT GetGdiCompatibleMetrics( 1239 FLOAT emSize, 1240 FLOAT pixelsPerDip, 1241 const(DWRITE_MATRIX)* transform, 1242 /*out*/ DWRITE_FONT_METRICS* fontFaceMetrics 1243 ); 1244 1245 /// <summary> 1246 /// Obtains glyph metrics in font design units with the return values compatible with what GDI would produce. 1247 /// Glyphs metrics are used for positioning of individual glyphs. 1248 /// </summary> 1249 /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param> 1250 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this 1251 /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param> 1252 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 1253 /// scaling specified by the font size and pixelsPerDip.</param> 1254 /// <param name="useGdiNatural"> 1255 /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text. 1256 /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font 1257 /// created with CLEARTYPE_NATURAL_QUALITY. 1258 /// </param> 1259 /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param> 1260 /// <param name="glyphCount">The number of elements in the glyphIndices array.</param> 1261 /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function. 1262 /// The metrics returned by this function are in font design units.</param> 1263 /// <param name="isSideways">Indicates whether the font is being used in a sideways run. 1264 /// This can affect the glyph metrics if the font has oblique simulation 1265 /// because sideways oblique simulation differs from non-sideways oblique simulation.</param> 1266 /// <returns> 1267 /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range 1268 /// for the current font face, E_INVALIDARG will be returned. 1269 /// </returns> 1270 HRESULT GetGdiCompatibleGlyphMetrics( 1271 FLOAT emSize, 1272 FLOAT pixelsPerDip, 1273 const(DWRITE_MATRIX)* transform, 1274 BOOL useGdiNatural, 1275 const(UINT16)* glyphIndices, 1276 UINT32 glyphCount, 1277 /*out*/ DWRITE_GLYPH_METRICS* glyphMetrics, 1278 BOOL isSideways = FALSE 1279 ); 1280 } 1281 1282 /// <summary> 1283 /// The font collection loader interface is used to construct a collection of fonts given a particular type of key. 1284 /// The font collection loader interface is recommended to be implemented by a singleton object. 1285 /// IMPORTANT: font collection loader implementations must not register themselves with a DirectWrite factory 1286 /// inside their constructors and must not unregister themselves in their destructors, because 1287 /// registration and unregistration operations increment and decrement the object reference count respectively. 1288 /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed 1289 /// outside of the font file loader implementation as a separate step. 1290 /// </summary> 1291 mixin( uuid!(IDWriteFontCollectionLoader, "cca920e4-52f0-492b-bfa8-29c72ee0a468") ); 1292 interface IDWriteFontCollectionLoader : IUnknown 1293 { 1294 extern(Windows): 1295 /// <summary> 1296 /// Creates a font file enumerator object that encapsulates a collection of font files. 1297 /// The font system calls back to this interface to create a font collection. 1298 /// </summary> 1299 /// <param name="factory">Factory associated with the loader.</param> 1300 /// <param name="collectionKey">Font collection key that uniquely identifies the collection of font files within 1301 /// the scope of the font collection loader being used.</param> 1302 /// <param name="collectionKeySize">Size of the font collection key in bytes.</param> 1303 /// <param name="fontFileEnumerator">Pointer to the newly created font file enumerator.</param> 1304 /// <returns> 1305 /// Standard HRESULT error code. 1306 /// </returns> 1307 HRESULT CreateEnumeratorFromKey( 1308 IDWriteFactory factory, 1309 const(void*) collectionKey, 1310 UINT32 collectionKeySize, 1311 /*out*/ IDWriteFontFileEnumerator* fontFileEnumerator 1312 ); 1313 } 1314 1315 /// <summary> 1316 /// The font file enumerator interface encapsulates a collection of font files. The font system uses this interface 1317 /// to enumerate font files when building a font collection. 1318 /// </summary> 1319 mixin( uuid!(IDWriteFontFileEnumerator, "72755049-5ff7-435d-8348-4be97cfa6c7c") ); 1320 interface IDWriteFontFileEnumerator : IUnknown 1321 { 1322 extern(Windows): 1323 /// <summary> 1324 /// Advances to the next font file in the collection. When it is first created, the enumerator is positioned 1325 /// before the first element of the collection and the first call to MoveNext advances to the first file. 1326 /// </summary> 1327 /// <param name="hasCurrentFile">Receives the value TRUE if the enumerator advances to a file, or FALSE if 1328 /// the enumerator advanced past the last file in the collection.</param> 1329 /// <returns> 1330 /// Standard HRESULT error code. 1331 /// </returns> 1332 HRESULT MoveNext( 1333 /*out*/ BOOL* hasCurrentFile 1334 ); 1335 1336 /// <summary> 1337 /// Gets a reference to the current font file. 1338 /// </summary> 1339 /// <param name="fontFile">Pointer to the newly created font file object.</param> 1340 /// <returns> 1341 /// Standard HRESULT error code. 1342 /// </returns> 1343 HRESULT GetCurrentFontFile( 1344 /*out*/ IDWriteFontFile* fontFile 1345 ); 1346 } 1347 1348 /// <summary> 1349 /// Represents a collection of strings indexed by locale name. 1350 /// </summary> 1351 mixin( uuid!(IDWriteLocalizedStrings, "08256209-099a-4b34-b86d-c22b110e7771") ); 1352 interface IDWriteLocalizedStrings : IUnknown 1353 { 1354 extern(Windows): 1355 /// <summary> 1356 /// Gets the number of language/string pairs. 1357 /// </summary> 1358 UINT32 GetCount(); 1359 1360 /// <summary> 1361 /// Gets the index of the item with the specified locale name. 1362 /// </summary> 1363 /// <param name="localeName">Locale name to look for.</param> 1364 /// <param name="index">Receives the zero-based index of the locale name/string pair.</param> 1365 /// <param name="exists">Receives TRUE if the locale name exists or FALSE if not.</param> 1366 /// <returns> 1367 /// Standard HRESULT error code. If the specified locale name does not exist, the return value is S_OK, 1368 /// but *index is UINT_MAX and *exists is FALSE. 1369 /// </returns> 1370 HRESULT FindLocaleName( 1371 const(WCHAR)* localeName, 1372 /*out*/ UINT32* index, 1373 /*out*/ BOOL* exists 1374 ); 1375 1376 /// <summary> 1377 /// Gets the length in characters (not including the null terminator) of the locale name with the specified index. 1378 /// </summary> 1379 /// <param name="index">Zero-based index of the locale name.</param> 1380 /// <param name="length">Receives the length in characters, not including the null terminator.</param> 1381 /// <returns> 1382 /// Standard HRESULT error code. 1383 /// </returns> 1384 HRESULT GetLocaleNameLength( 1385 UINT32 index, 1386 /*out*/ UINT32* length 1387 ); 1388 1389 /// <summary> 1390 /// Copies the locale name with the specified index to the specified array. 1391 /// </summary> 1392 /// <param name="index">Zero-based index of the locale name.</param> 1393 /// <param name="localeName">Character array that receives the locale name.</param> 1394 /// <param name="size">Size of the array in characters. The size must include space for the terminating 1395 /// null character.</param> 1396 /// <returns> 1397 /// Standard HRESULT error code. 1398 /// </returns> 1399 HRESULT GetLocaleName( 1400 UINT32 index, 1401 /*out*/ WCHAR* localeName, 1402 UINT32 size 1403 ); 1404 1405 /// <summary> 1406 /// Gets the length in characters (not including the null terminator) of the string with the specified index. 1407 /// </summary> 1408 /// <param name="index">Zero-based index of the string.</param> 1409 /// <param name="length">Receives the length in characters, not including the null terminator.</param> 1410 /// <returns> 1411 /// Standard HRESULT error code. 1412 /// </returns> 1413 HRESULT GetStringLength( 1414 UINT32 index, 1415 /*out*/ UINT32* length 1416 ); 1417 1418 /// <summary> 1419 /// Copies the string with the specified index to the specified array. 1420 /// </summary> 1421 /// <param name="index">Zero-based index of the string.</param> 1422 /// <param name="stringBuffer">Character array that receives the string.</param> 1423 /// <param name="size">Size of the array in characters. The size must include space for the terminating 1424 /// null character.</param> 1425 /// <returns> 1426 /// Standard HRESULT error code. 1427 /// </returns> 1428 HRESULT GetString( 1429 UINT32 index, 1430 /*out*/ WCHAR* stringBuffer, 1431 UINT32 size 1432 ); 1433 } 1434 1435 /// <summary> 1436 /// The IDWriteFontCollection encapsulates a collection of fonts. 1437 /// </summary> 1438 mixin( uuid!(IDWriteFontCollection, "a84cee02-3eea-4eee-a827-87c1a02a0fcc") ); 1439 interface IDWriteFontCollection : IUnknown 1440 { 1441 extern(Windows): 1442 /// <summary> 1443 /// Gets the number of font families in the collection. 1444 /// </summary> 1445 UINT32 GetFontFamilyCount(); 1446 1447 /// <summary> 1448 /// Creates a font family object given a zero-based font family index. 1449 /// </summary> 1450 /// <param name="index">Zero-based index of the font family.</param> 1451 /// <param name="fontFamily">Receives a pointer the newly created font family object.</param> 1452 /// <returns> 1453 /// Standard HRESULT error code. 1454 /// </returns> 1455 HRESULT GetFontFamily( 1456 UINT32 index, 1457 /*out*/ IDWriteFontFamily* fontFamily 1458 ); 1459 1460 /// <summary> 1461 /// Finds the font family with the specified family name. 1462 /// </summary> 1463 /// <param name="familyName">Name of the font family. The name is not case-sensitive but must otherwise exactly match a family name in the collection.</param> 1464 /// <param name="index">Receives the zero-based index of the matching font family if the family name was found or UINT_MAX otherwise.</param> 1465 /// <param name="exists">Receives TRUE if the family name exists or FALSE otherwise.</param> 1466 /// <returns> 1467 /// Standard HRESULT error code. If the specified family name does not exist, the return value is S_OK, but *index is UINT_MAX and *exists is FALSE. 1468 /// </returns> 1469 HRESULT FindFamilyName( 1470 const(WCHAR)* familyName, 1471 /*out*/ UINT32* index, 1472 /*out*/ BOOL* exists 1473 ); 1474 1475 /// <summary> 1476 /// Gets the font object that corresponds to the same physical font as the specified font face object. The specified physical font must belong 1477 /// to the font collection. 1478 /// </summary> 1479 /// <param name="fontFace">Font face object that specifies the physical font.</param> 1480 /// <param name="font">Receives a pointer to the newly created font object if successful or NULL otherwise.</param> 1481 /// <returns> 1482 /// Standard HRESULT error code. If the specified physical font is not part of the font collection the return value is DWRITE_E_NOFONT. 1483 /// </returns> 1484 HRESULT GetFontFromFontFace( 1485 IDWriteFontFace fontFace, 1486 /*out*/ IDWriteFont* font 1487 ); 1488 } 1489 1490 /// <summary> 1491 /// The IDWriteFontList interface represents a list of fonts. 1492 /// </summary> 1493 mixin( uuid!(IDWriteFontList, "1a0d8438-1d97-4ec1-aef9-a2fb86ed6acb") ); 1494 interface IDWriteFontList : IUnknown 1495 { 1496 extern(Windows): 1497 /// <summary> 1498 /// Gets the font collection that contains the fonts. 1499 /// </summary> 1500 /// <param name="fontCollection">Receives a pointer to the font collection object.</param> 1501 /// <returns> 1502 /// Standard HRESULT error code. 1503 /// </returns> 1504 HRESULT GetFontCollection( 1505 /*out*/ IDWriteFontCollection* fontCollection 1506 ); 1507 1508 /// <summary> 1509 /// Gets the number of fonts in the font list. 1510 /// </summary> 1511 UINT32 GetFontCount(); 1512 1513 /// <summary> 1514 /// Gets a font given its zero-based index. 1515 /// </summary> 1516 /// <param name="index">Zero-based index of the font in the font list.</param> 1517 /// <param name="font">Receives a pointer to the newly created font object.</param> 1518 /// <returns> 1519 /// Standard HRESULT error code. 1520 /// </returns> 1521 HRESULT GetFont( 1522 UINT32 index, 1523 /*out*/ IDWriteFont* font 1524 ); 1525 } 1526 1527 /// <summary> 1528 /// The IDWriteFontFamily interface represents a set of fonts that share the same design but are differentiated 1529 /// by weight, stretch, and style. 1530 /// </summary> 1531 mixin( uuid!(IDWriteFontFamily, "da20d8ef-812a-4c43-9802-62ec4abd7add") ); 1532 interface IDWriteFontFamily : IDWriteFontList 1533 { 1534 extern(Windows): 1535 /// <summary> 1536 /// Creates a localized strings object that contains the family names for the font family, indexed by locale name. 1537 /// </summary> 1538 /// <param name="names">Receives a pointer to the newly created localized strings object.</param> 1539 /// <returns> 1540 /// Standard HRESULT error code. 1541 /// </returns> 1542 HRESULT GetFamilyNames( 1543 /*out*/ IDWriteLocalizedStrings* names 1544 ); 1545 1546 /// <summary> 1547 /// Gets the font that best matches the specified properties. 1548 /// </summary> 1549 /// <param name="weight">Requested font weight.</param> 1550 /// <param name="stretch">Requested font stretch.</param> 1551 /// <param name="style">Requested font style.</param> 1552 /// <param name="matchingFont">Receives a pointer to the newly created font object.</param> 1553 /// <returns> 1554 /// Standard HRESULT error code. 1555 /// </returns> 1556 HRESULT GetFirstMatchingFont( 1557 DWRITE_FONT_WEIGHT weight, 1558 DWRITE_FONT_STRETCH stretch, 1559 DWRITE_FONT_STYLE style, 1560 /*out*/ IDWriteFont* matchingFont 1561 ); 1562 1563 /// <summary> 1564 /// Gets a list of fonts in the font family ranked in order of how well they match the specified properties. 1565 /// </summary> 1566 /// <param name="weight">Requested font weight.</param> 1567 /// <param name="stretch">Requested font stretch.</param> 1568 /// <param name="style">Requested font style.</param> 1569 /// <param name="matchingFonts">Receives a pointer to the newly created font list object.</param> 1570 /// <returns> 1571 /// Standard HRESULT error code. 1572 /// </returns> 1573 HRESULT GetMatchingFonts( 1574 DWRITE_FONT_WEIGHT weight, 1575 DWRITE_FONT_STRETCH stretch, 1576 DWRITE_FONT_STYLE style, 1577 IDWriteFontList* matchingFonts 1578 ); 1579 } 1580 1581 /// <summary> 1582 /// The IDWriteFont interface represents a physical font in a font collection. 1583 /// </summary> 1584 mixin( uuid!(IDWriteFont, "acd16696-8c14-4f5d-877e-fe3fc1d32737") ); 1585 interface IDWriteFont : IUnknown 1586 { 1587 extern(Windows): 1588 /// <summary> 1589 /// Gets the font family to which the specified font belongs. 1590 /// </summary> 1591 /// <param name="fontFamily">Receives a pointer to the font family object.</param> 1592 /// <returns> 1593 /// Standard HRESULT error code. 1594 /// </returns> 1595 HRESULT GetFontFamily( 1596 /*out*/ IDWriteFontFamily* fontFamily 1597 ); 1598 1599 /// <summary> 1600 /// Gets the weight of the specified font. 1601 /// </summary> 1602 DWRITE_FONT_WEIGHT GetWeight(); 1603 1604 /// <summary> 1605 /// Gets the stretch (aka. width) of the specified font. 1606 /// </summary> 1607 DWRITE_FONT_STRETCH GetStretch(); 1608 1609 /// <summary> 1610 /// Gets the style (aka. slope) of the specified font. 1611 /// </summary> 1612 DWRITE_FONT_STYLE GetStyle(); 1613 1614 /// <summary> 1615 /// Returns TRUE if the font is a symbol font or FALSE if not. 1616 /// </summary> 1617 BOOL IsSymbolFont(); 1618 1619 /// <summary> 1620 /// Gets a localized strings collection containing the face names for the font (e.g., Regular or Bold), indexed by locale name. 1621 /// </summary> 1622 /// <param name="names">Receives a pointer to the newly created localized strings object.</param> 1623 /// <returns> 1624 /// Standard HRESULT error code. 1625 /// </returns> 1626 HRESULT GetFaceNames( 1627 /*out*/ IDWriteLocalizedStrings* names 1628 ); 1629 1630 /// <summary> 1631 /// Gets a localized strings collection containing the specified informational strings, indexed by locale name. 1632 /// </summary> 1633 /// <param name="informationalStringID">Identifies the string to get.</param> 1634 /// <param name="informationalStrings">Receives a pointer to the newly created localized strings object.</param> 1635 /// <param name="exists">Receives the value TRUE if the font contains the specified string ID or FALSE if not.</param> 1636 /// <returns> 1637 /// Standard HRESULT error code. If the font does not contain the specified string, the return value is S_OK but 1638 /// informationalStrings receives a NULL pointer and exists receives the value FALSE. 1639 /// </returns> 1640 HRESULT GetInformationalStrings( 1641 DWRITE_INFORMATIONAL_STRING_ID informationalStringID, 1642 /*out*/ IDWriteLocalizedStrings* informationalStrings, 1643 /*out*/ BOOL* exists 1644 ); 1645 1646 /// <summary> 1647 /// Gets a value that indicates what simulation are applied to the specified font. 1648 /// </summary> 1649 DWRITE_FONT_SIMULATIONS GetSimulations(); 1650 1651 /// <summary> 1652 /// Gets the metrics for the font. 1653 /// </summary> 1654 /// <param name="fontMetrics">Receives the font metrics.</param> 1655 void GetMetrics( 1656 /*out*/ DWRITE_FONT_METRICS* fontMetrics 1657 ); 1658 1659 /// <summary> 1660 /// Determines whether the font supports the specified character. 1661 /// </summary> 1662 /// <param name="unicodeValue">Unicode (UCS-4) character value.</param> 1663 /// <param name="exists">Receives the value TRUE if the font supports the specified character or FALSE if not.</param> 1664 /// <returns> 1665 /// Standard HRESULT error code. 1666 /// </returns> 1667 HRESULT HasCharacter( 1668 UINT32 unicodeValue, 1669 /*out*/ BOOL* exists 1670 ); 1671 1672 /// <summary> 1673 /// Creates a font face object for the font. 1674 /// </summary> 1675 /// <param name="fontFace">Receives a pointer to the newly created font face object.</param> 1676 /// <returns> 1677 /// Standard HRESULT error code. 1678 /// </returns> 1679 HRESULT CreateFontFace( 1680 /*out*/ IDWriteFontFace* fontFace 1681 ); 1682 } 1683 1684 /// <summary> 1685 /// Direction for how reading progresses. 1686 /// </summary> 1687 alias DWRITE_READING_DIRECTION = int; 1688 enum : DWRITE_READING_DIRECTION 1689 { 1690 /// <summary> 1691 /// Reading progresses from left to right. 1692 /// </summary> 1693 DWRITE_READING_DIRECTION_LEFT_TO_RIGHT = 0, 1694 1695 /// <summary> 1696 /// Reading progresses from right to left. 1697 /// </summary> 1698 DWRITE_READING_DIRECTION_RIGHT_TO_LEFT = 1, 1699 1700 /// <summary> 1701 /// Reading progresses from top to bottom. 1702 /// </summary> 1703 DWRITE_READING_DIRECTION_TOP_TO_BOTTOM = 2, 1704 1705 /// <summary> 1706 /// Reading progresses from bottom to top. 1707 /// </summary> 1708 DWRITE_READING_DIRECTION_BOTTOM_TO_TOP = 3, 1709 } 1710 1711 /// <summary> 1712 /// Direction for how lines of text are placed relative to one another. 1713 /// </summary> 1714 alias DWRITE_FLOW_DIRECTION = int; 1715 enum : DWRITE_FLOW_DIRECTION 1716 { 1717 /// <summary> 1718 /// Text lines are placed from top to bottom. 1719 /// </summary> 1720 DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM = 0, 1721 1722 /// <summary> 1723 /// Text lines are placed from bottom to top. 1724 /// </summary> 1725 DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP = 1, 1726 1727 /// <summary> 1728 /// Text lines are placed from left to right. 1729 /// </summary> 1730 DWRITE_FLOW_DIRECTION_LEFT_TO_RIGHT = 2, 1731 1732 /// <summary> 1733 /// Text lines are placed from right to left. 1734 /// </summary> 1735 DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT = 3, 1736 } 1737 1738 /// <summary> 1739 /// Alignment of paragraph text along the reading direction axis relative to 1740 /// the leading and trailing edge of the layout box. 1741 /// </summary> 1742 alias DWRITE_TEXT_ALIGNMENT = int; 1743 enum : DWRITE_TEXT_ALIGNMENT 1744 { 1745 /// <summary> 1746 /// The leading edge of the paragraph text is aligned to the layout box's leading edge. 1747 /// </summary> 1748 DWRITE_TEXT_ALIGNMENT_LEADING, 1749 1750 /// <summary> 1751 /// The trailing edge of the paragraph text is aligned to the layout box's trailing edge. 1752 /// </summary> 1753 DWRITE_TEXT_ALIGNMENT_TRAILING, 1754 1755 /// <summary> 1756 /// The center of the paragraph text is aligned to the center of the layout box. 1757 /// </summary> 1758 DWRITE_TEXT_ALIGNMENT_CENTER, 1759 1760 /// <summary> 1761 /// Align text to the leading side, and also justify text to fill the lines. 1762 /// </summary> 1763 DWRITE_TEXT_ALIGNMENT_JUSTIFIED 1764 } 1765 1766 /// <summary> 1767 /// Alignment of paragraph text along the flow direction axis relative to the 1768 /// flow's beginning and ending edge of the layout box. 1769 /// </summary> 1770 alias DWRITE_PARAGRAPH_ALIGNMENT = int; 1771 enum : DWRITE_PARAGRAPH_ALIGNMENT 1772 { 1773 /// <summary> 1774 /// The first line of paragraph is aligned to the flow's beginning edge of the layout box. 1775 /// </summary> 1776 DWRITE_PARAGRAPH_ALIGNMENT_NEAR, 1777 1778 /// <summary> 1779 /// The last line of paragraph is aligned to the flow's ending edge of the layout box. 1780 /// </summary> 1781 DWRITE_PARAGRAPH_ALIGNMENT_FAR, 1782 1783 /// <summary> 1784 /// The center of the paragraph is aligned to the center of the flow of the layout box. 1785 /// </summary> 1786 DWRITE_PARAGRAPH_ALIGNMENT_CENTER 1787 } 1788 1789 /// <summary> 1790 /// Word wrapping in multiline paragraph. 1791 /// </summary> 1792 alias DWRITE_WORD_WRAPPING = int; 1793 enum : DWRITE_WORD_WRAPPING 1794 { 1795 /// <summary> 1796 /// Words are broken across lines to avoid text overflowing the layout box. 1797 /// </summary> 1798 DWRITE_WORD_WRAPPING_WRAP = 0, 1799 1800 /// <summary> 1801 /// Words are kept within the same line even when it overflows the layout box. 1802 /// This option is often used with scrolling to reveal overflow text. 1803 /// </summary> 1804 DWRITE_WORD_WRAPPING_NO_WRAP = 1, 1805 1806 /// <summary> 1807 /// Words are broken across lines to avoid text overflowing the layout box. 1808 /// Emergency wrapping occurs if the word is larger than the maximum width. 1809 /// </summary> 1810 DWRITE_WORD_WRAPPING_EMERGENCY_BREAK = 2, 1811 1812 /// <summary> 1813 /// Only wrap whole words, never breaking words (emergency wrapping) when the 1814 /// layout width is too small for even a single word. 1815 /// </summary> 1816 DWRITE_WORD_WRAPPING_WHOLE_WORD = 3, 1817 1818 /// <summary> 1819 /// Wrap between any valid characters clusters. 1820 /// </summary> 1821 DWRITE_WORD_WRAPPING_CHARACTER = 4, 1822 }; 1823 1824 /// <summary> 1825 /// The method used for line spacing in layout. 1826 /// </summary> 1827 alias DWRITE_LINE_SPACING_METHOD = int; 1828 enum : DWRITE_LINE_SPACING_METHOD 1829 { 1830 /// <summary> 1831 /// Line spacing depends solely on the content, growing to accommodate the size of fonts and inline objects. 1832 /// </summary> 1833 DWRITE_LINE_SPACING_METHOD_DEFAULT, 1834 1835 /// <summary> 1836 /// Lines are explicitly set to uniform spacing, regardless of contained font sizes. 1837 /// This can be useful to avoid the uneven appearance that can occur from font fallback. 1838 /// </summary> 1839 DWRITE_LINE_SPACING_METHOD_UNIFORM 1840 } 1841 1842 /// <summary> 1843 /// Text granularity used to trim text overflowing the layout box. 1844 /// </summary> 1845 alias DWRITE_TRIMMING_GRANULARITY = int; 1846 enum : DWRITE_TRIMMING_GRANULARITY 1847 { 1848 /// <summary> 1849 /// No trimming occurs. Text flows beyond the layout width. 1850 /// </summary> 1851 DWRITE_TRIMMING_GRANULARITY_NONE, 1852 1853 /// <summary> 1854 /// Trimming occurs at character cluster boundary. 1855 /// </summary> 1856 DWRITE_TRIMMING_GRANULARITY_CHARACTER, 1857 1858 /// <summary> 1859 /// Trimming occurs at word boundary. 1860 /// </summary> 1861 DWRITE_TRIMMING_GRANULARITY_WORD 1862 } 1863 1864 /// <summary> 1865 /// Typographic feature of text supplied by the font. 1866 /// </summary> 1867 alias DWRITE_FONT_FEATURE_TAG = int; 1868 enum : DWRITE_FONT_FEATURE_TAG 1869 { 1870 DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS = 0x63726661, // 'afrc' 1871 DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS = 0x63703263, // 'c2pc' 1872 DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS = 0x63733263, // 'c2sc' 1873 DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES = 0x746c6163, // 'calt' 1874 DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS = 0x65736163, // 'case' 1875 DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION = 0x706d6363, // 'ccmp' 1876 DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES = 0x67696c63, // 'clig' 1877 DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING = 0x70737063, // 'cpsp' 1878 DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH = 0x68777363, // 'cswh' 1879 DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING = 0x73727563, // 'curs' 1880 DWRITE_FONT_FEATURE_TAG_DEFAULT = 0x746c6664, // 'dflt' 1881 DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES = 0x67696c64, // 'dlig' 1882 DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS = 0x74707865, // 'expt' 1883 DWRITE_FONT_FEATURE_TAG_FRACTIONS = 0x63617266, // 'frac' 1884 DWRITE_FONT_FEATURE_TAG_FULL_WIDTH = 0x64697766, // 'fwid' 1885 DWRITE_FONT_FEATURE_TAG_HALF_FORMS = 0x666c6168, // 'half' 1886 DWRITE_FONT_FEATURE_TAG_HALANT_FORMS = 0x6e6c6168, // 'haln' 1887 DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH = 0x746c6168, // 'halt' 1888 DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS = 0x74736968, // 'hist' 1889 DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES = 0x616e6b68, // 'hkna' 1890 DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES = 0x67696c68, // 'hlig' 1891 DWRITE_FONT_FEATURE_TAG_HALF_WIDTH = 0x64697768, // 'hwid' 1892 DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS = 0x6f6a6f68, // 'hojo' 1893 DWRITE_FONT_FEATURE_TAG_JIS04_FORMS = 0x3430706a, // 'jp04' 1894 DWRITE_FONT_FEATURE_TAG_JIS78_FORMS = 0x3837706a, // 'jp78' 1895 DWRITE_FONT_FEATURE_TAG_JIS83_FORMS = 0x3338706a, // 'jp83' 1896 DWRITE_FONT_FEATURE_TAG_JIS90_FORMS = 0x3039706a, // 'jp90' 1897 DWRITE_FONT_FEATURE_TAG_KERNING = 0x6e72656b, // 'kern' 1898 DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES = 0x6167696c, // 'liga' 1899 DWRITE_FONT_FEATURE_TAG_LINING_FIGURES = 0x6d756e6c, // 'lnum' 1900 DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS = 0x6c636f6c, // 'locl' 1901 DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING = 0x6b72616d, // 'mark' 1902 DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK = 0x6b72676d, // 'mgrk' 1903 DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING = 0x6b6d6b6d, // 'mkmk' 1904 DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS = 0x746c616e, // 'nalt' 1905 DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS = 0x6b636c6e, // 'nlck' 1906 DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES = 0x6d756e6f, // 'onum' 1907 DWRITE_FONT_FEATURE_TAG_ORDINALS = 0x6e64726f, // 'ordn' 1908 DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH = 0x746c6170, // 'palt' 1909 DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS = 0x70616370, // 'pcap' 1910 DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES = 0x6d756e70, // 'pnum' 1911 DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS = 0x64697770, // 'pwid' 1912 DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS = 0x64697771, // 'qwid' 1913 DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES = 0x67696c72, // 'rlig' 1914 DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS = 0x79627572, // 'ruby' 1915 DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES = 0x746c6173, // 'salt' 1916 DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS = 0x666e6973, // 'sinf' 1917 DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS = 0x70636d73, // 'smcp' 1918 DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS = 0x6c706d73, // 'smpl' 1919 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1 = 0x31307373, // 'ss01' 1920 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2 = 0x32307373, // 'ss02' 1921 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3 = 0x33307373, // 'ss03' 1922 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4 = 0x34307373, // 'ss04' 1923 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5 = 0x35307373, // 'ss05' 1924 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6 = 0x36307373, // 'ss06' 1925 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7 = 0x37307373, // 'ss07' 1926 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8 = 0x38307373, // 'ss08' 1927 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9 = 0x39307373, // 'ss09' 1928 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10 = 0x30317373, // 'ss10' 1929 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11 = 0x31317373, // 'ss11' 1930 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12 = 0x32317373, // 'ss12' 1931 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13 = 0x33317373, // 'ss13' 1932 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14 = 0x34317373, // 'ss14' 1933 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15 = 0x35317373, // 'ss15' 1934 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16 = 0x36317373, // 'ss16' 1935 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17 = 0x37317373, // 'ss17' 1936 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18 = 0x38317373, // 'ss18' 1937 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19 = 0x39317373, // 'ss19' 1938 DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20 = 0x30327373, // 'ss20' 1939 DWRITE_FONT_FEATURE_TAG_SUBSCRIPT = 0x73627573, // 'subs' 1940 DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT = 0x73707573, // 'sups' 1941 DWRITE_FONT_FEATURE_TAG_SWASH = 0x68737773, // 'swsh' 1942 DWRITE_FONT_FEATURE_TAG_TITLING = 0x6c746974, // 'titl' 1943 DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS = 0x6d616e74, // 'tnam' 1944 DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES = 0x6d756e74, // 'tnum' 1945 DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS = 0x64617274, // 'trad' 1946 DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS = 0x64697774, // 'twid' 1947 DWRITE_FONT_FEATURE_TAG_UNICASE = 0x63696e75, // 'unic' 1948 DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING = 0x74726576, // 'vert' 1949 DWRITE_FONT_FEATURE_TAG_VERTICAL_ALTERNATES_AND_ROTATION = 0x32747276, // 'vrt2' 1950 DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO = 0x6f72657a, // 'zero' 1951 } 1952 1953 /// <summary> 1954 /// The DWRITE_TEXT_RANGE structure specifies a range of text positions where format is applied. 1955 /// </summary> 1956 struct DWRITE_TEXT_RANGE 1957 { 1958 /// <summary> 1959 /// The start text position of the range. 1960 /// </summary> 1961 UINT32 startPosition; 1962 1963 /// <summary> 1964 /// The number of text positions in the range. 1965 /// </summary> 1966 UINT32 length; 1967 } 1968 1969 /// <summary> 1970 /// The DWRITE_FONT_FEATURE structure specifies properties used to identify and execute typographic feature in the font. 1971 /// </summary> 1972 struct DWRITE_FONT_FEATURE 1973 { 1974 /// <summary> 1975 /// The feature OpenType name identifier. 1976 /// </summary> 1977 DWRITE_FONT_FEATURE_TAG nameTag; 1978 1979 /// <summary> 1980 /// Execution parameter of the feature. 1981 /// </summary> 1982 /// <remarks> 1983 /// The parameter should be non-zero to enable the feature. Once enabled, a feature can't be disabled again within 1984 /// the same range. Features requiring a selector use this value to indicate the selector index. 1985 /// </remarks> 1986 UINT32 parameter; 1987 } 1988 1989 /// <summary> 1990 /// Defines a set of typographic features to be applied during shaping. 1991 /// Notice the character range which this feature list spans is specified 1992 /// as a separate parameter to GetGlyphs. 1993 /// </summary> 1994 struct DWRITE_TYPOGRAPHIC_FEATURES 1995 { 1996 /// <summary> 1997 /// Array of font features. 1998 /// </summary> 1999 DWRITE_FONT_FEATURE* features; 2000 2001 /// <summary> 2002 /// The number of features. 2003 /// </summary> 2004 UINT32 featureCount; 2005 } 2006 2007 /// <summary> 2008 /// The DWRITE_TRIMMING structure specifies the trimming option for text overflowing the layout box. 2009 /// </summary> 2010 struct DWRITE_TRIMMING 2011 { 2012 /// <summary> 2013 /// Text granularity of which trimming applies. 2014 /// </summary> 2015 DWRITE_TRIMMING_GRANULARITY granularity; 2016 2017 /// <summary> 2018 /// Character code used as the delimiter signaling the beginning of the portion of text to be preserved, 2019 /// most useful for path ellipsis, where the delimiter would be a slash. 2020 /// </summary> 2021 UINT32 delimiter; 2022 2023 /// <summary> 2024 /// How many occurrences of the delimiter to step back. 2025 /// </summary> 2026 UINT32 delimiterCount; 2027 } 2028 2029 2030 /// <summary> 2031 /// The format of text used for text layout. 2032 /// </summary> 2033 /// <remarks> 2034 /// This object may not be thread-safe and it may carry the state of text format change. 2035 /// </remarks> 2036 mixin( uuid!(IDWriteTextFormat, "9c906818-31d7-4fd3-a151-7c5e225db55a") ); 2037 interface IDWriteTextFormat : IUnknown 2038 { 2039 extern(Windows): 2040 /// <summary> 2041 /// Set alignment option of text relative to layout box's leading and trailing edge. 2042 /// </summary> 2043 /// <param name="textAlignment">Text alignment option</param> 2044 /// <returns> 2045 /// Standard HRESULT error code. 2046 /// </returns> 2047 HRESULT SetTextAlignment( 2048 DWRITE_TEXT_ALIGNMENT textAlignment 2049 ); 2050 2051 /// <summary> 2052 /// Set alignment option of paragraph relative to layout box's top and bottom edge. 2053 /// </summary> 2054 /// <param name="paragraphAlignment">Paragraph alignment option</param> 2055 /// <returns> 2056 /// Standard HRESULT error code. 2057 /// </returns> 2058 HRESULT SetParagraphAlignment( 2059 DWRITE_PARAGRAPH_ALIGNMENT paragraphAlignment 2060 ); 2061 2062 /// <summary> 2063 /// Set word wrapping option. 2064 /// </summary> 2065 /// <param name="wordWrapping">Word wrapping option</param> 2066 /// <returns> 2067 /// Standard HRESULT error code. 2068 /// </returns> 2069 HRESULT SetWordWrapping( 2070 DWRITE_WORD_WRAPPING wordWrapping 2071 ); 2072 2073 /// <summary> 2074 /// Set paragraph reading direction. 2075 /// </summary> 2076 /// <param name="readingDirection">Text reading direction</param> 2077 /// <returns> 2078 /// Standard HRESULT error code. 2079 /// </returns> 2080 /// <remarks> 2081 /// The flow direction must be perpendicular to the reading direction. 2082 /// Setting both to a vertical direction or both to horizontal yields 2083 /// DWRITE_E_FLOWDIRECTIONCONFLICTS when calling GetMetrics or Draw. 2084 /// </remark> 2085 HRESULT SetReadingDirection( 2086 DWRITE_READING_DIRECTION readingDirection 2087 ); 2088 2089 /// <summary> 2090 /// Set paragraph flow direction. 2091 /// </summary> 2092 /// <param name="flowDirection">Paragraph flow direction</param> 2093 /// <returns> 2094 /// Standard HRESULT error code. 2095 /// </returns> 2096 /// <remarks> 2097 /// The flow direction must be perpendicular to the reading direction. 2098 /// Setting both to a vertical direction or both to horizontal yields 2099 /// DWRITE_E_FLOWDIRECTIONCONFLICTS when calling GetMetrics or Draw. 2100 /// </remark> 2101 HRESULT SetFlowDirection( 2102 DWRITE_FLOW_DIRECTION flowDirection 2103 ); 2104 2105 /// <summary> 2106 /// Set incremental tab stop position. 2107 /// </summary> 2108 /// <param name="incrementalTabStop">The incremental tab stop value</param> 2109 /// <returns> 2110 /// Standard HRESULT error code. 2111 /// </returns> 2112 HRESULT SetIncrementalTabStop( 2113 FLOAT incrementalTabStop 2114 ); 2115 2116 /// <summary> 2117 /// Set trimming options for any trailing text exceeding the layout width 2118 /// or for any far text exceeding the layout height. 2119 /// </summary> 2120 /// <param name="trimmingOptions">Text trimming options.</param> 2121 /// <param name="trimmingSign">Application-defined omission sign. This parameter may be NULL if no trimming sign is desired.</param> 2122 /// <remarks> 2123 /// Any inline object can be used for the trimming sign, but CreateEllipsisTrimmingSign 2124 /// provides a typical ellipsis symbol. Trimming is also useful vertically for hiding 2125 /// partial lines. 2126 /// </remarks> 2127 /// <returns> 2128 /// Standard HRESULT error code. 2129 /// </returns> 2130 HRESULT SetTrimming( 2131 const(DWRITE_TRIMMING)* trimmingOptions, 2132 IDWriteInlineObject trimmingSign 2133 ); 2134 2135 /// <summary> 2136 /// Set line spacing. 2137 /// </summary> 2138 /// <param name="lineSpacingMethod">How to determine line height.</param> 2139 /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param> 2140 /// <param name="baseline">Distance from top of line to baseline. A reasonable ratio to lineSpacing is 80%.</param> 2141 /// <remarks> 2142 /// For the default method, spacing depends solely on the content. 2143 /// For uniform spacing, the given line height will override the content. 2144 /// </remarks> 2145 /// <returns> 2146 /// Standard HRESULT error code. 2147 /// </returns> 2148 HRESULT SetLineSpacing( 2149 DWRITE_LINE_SPACING_METHOD lineSpacingMethod, 2150 FLOAT lineSpacing, 2151 FLOAT baseline 2152 ); 2153 2154 /// <summary> 2155 /// Get alignment option of text relative to layout box's leading and trailing edge. 2156 /// </summary> 2157 DWRITE_TEXT_ALIGNMENT GetTextAlignment(); 2158 2159 /// <summary> 2160 /// Get alignment option of paragraph relative to layout box's top and bottom edge. 2161 /// </summary> 2162 DWRITE_PARAGRAPH_ALIGNMENT GetParagraphAlignment(); 2163 2164 /// <summary> 2165 /// Get word wrapping option. 2166 /// </summary> 2167 DWRITE_WORD_WRAPPING GetWordWrapping(); 2168 2169 /// <summary> 2170 /// Get paragraph reading direction. 2171 /// </summary> 2172 DWRITE_READING_DIRECTION GetReadingDirection(); 2173 2174 /// <summary> 2175 /// Get paragraph flow direction. 2176 /// </summary> 2177 DWRITE_FLOW_DIRECTION GetFlowDirection(); 2178 2179 /// <summary> 2180 /// Get incremental tab stop position. 2181 /// </summary> 2182 FLOAT GetIncrementalTabStop(); 2183 2184 /// <summary> 2185 /// Get trimming options for text overflowing the layout width. 2186 /// </summary> 2187 /// <param name="trimmingOptions">Text trimming options.</param> 2188 /// <param name="trimmingSign">Trimming omission sign. This parameter may be NULL.</param> 2189 /// <returns> 2190 /// Standard HRESULT error code. 2191 /// </returns> 2192 HRESULT GetTrimming( 2193 /*out*/ DWRITE_TRIMMING* trimmingOptions, 2194 /*out*/ IDWriteInlineObject* trimmingSign 2195 ); 2196 2197 /// <summary> 2198 /// Get line spacing. 2199 /// </summary> 2200 /// <param name="lineSpacingMethod">How line height is determined.</param> 2201 /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param> 2202 /// <param name="baseline">Distance from top of line to baseline.</param> 2203 /// <returns> 2204 /// Standard HRESULT error code. 2205 /// </returns> 2206 HRESULT GetLineSpacing( 2207 /*out*/ DWRITE_LINE_SPACING_METHOD* lineSpacingMethod, 2208 /*out*/ FLOAT* lineSpacing, 2209 /*out*/ FLOAT* baseline 2210 ); 2211 2212 /// <summary> 2213 /// Get the font collection. 2214 /// </summary> 2215 /// <param name="fontCollection">The current font collection.</param> 2216 /// <returns> 2217 /// Standard HRESULT error code. 2218 /// </returns> 2219 HRESULT GetFontCollection( 2220 /*out*/ IDWriteFontCollection* fontCollection 2221 ); 2222 2223 /// <summary> 2224 /// Get the length of the font family name, in characters, not including the terminating NULL character. 2225 /// </summary> 2226 UINT32 GetFontFamilyNameLength(); 2227 2228 /// <summary> 2229 /// Get a copy of the font family name. 2230 /// </summary> 2231 /// <param name="fontFamilyName">Character array that receives the current font family name</param> 2232 /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> 2233 /// <returns> 2234 /// Standard HRESULT error code. 2235 /// </returns> 2236 HRESULT GetFontFamilyName( 2237 /*out*/ WCHAR* fontFamilyName, 2238 UINT32 nameSize 2239 ); 2240 2241 /// <summary> 2242 /// Get the font weight. 2243 /// </summary> 2244 DWRITE_FONT_WEIGHT GetFontWeight(); 2245 2246 /// <summary> 2247 /// Get the font style. 2248 /// </summary> 2249 DWRITE_FONT_STYLE GetFontStyle(); 2250 2251 /// <summary> 2252 /// Get the font stretch. 2253 /// </summary> 2254 DWRITE_FONT_STRETCH GetFontStretch(); 2255 2256 /// <summary> 2257 /// Get the font em height. 2258 /// </summary> 2259 FLOAT GetFontSize(); 2260 2261 /// <summary> 2262 /// Get the length of the locale name, in characters, not including the terminating NULL character. 2263 /// </summary> 2264 UINT32 GetLocaleNameLength(); 2265 2266 /// <summary> 2267 /// Get a copy of the locale name. 2268 /// </summary> 2269 /// <param name="localeName">Character array that receives the current locale name</param> 2270 /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> 2271 /// <returns> 2272 /// Standard HRESULT error code. 2273 /// </returns> 2274 HRESULT GetLocaleName( 2275 /*out*/ WCHAR* localeName, 2276 UINT32 nameSize 2277 ); 2278 } 2279 2280 2281 /// <summary> 2282 /// Font typography setting. 2283 /// </summary> 2284 mixin( uuid!(IDWriteTypography, "55f1112b-1dc2-4b3c-9541-f46894ed85b6") ); 2285 interface IDWriteTypography : IUnknown 2286 { 2287 extern(Windows): 2288 /// <summary> 2289 /// Add font feature. 2290 /// </summary> 2291 /// <param name="fontFeature">The font feature to add.</param> 2292 /// <returns> 2293 /// Standard HRESULT error code. 2294 /// </returns> 2295 HRESULT AddFontFeature( 2296 DWRITE_FONT_FEATURE fontFeature 2297 ); 2298 2299 /// <summary> 2300 /// Get the number of font features. 2301 /// </summary> 2302 UINT32 GetFontFeatureCount(); 2303 2304 /// <summary> 2305 /// Get the font feature at the specified index. 2306 /// </summary> 2307 /// <param name="fontFeatureIndex">The zero-based index of the font feature to get.</param> 2308 /// <param name="fontFeature">The font feature.</param> 2309 /// <returns> 2310 /// Standard HRESULT error code. 2311 /// </returns> 2312 HRESULT GetFontFeature( 2313 UINT32 fontFeatureIndex, 2314 /*out*/ DWRITE_FONT_FEATURE* fontFeature 2315 ); 2316 } 2317 2318 alias DWRITE_SCRIPT_SHAPES = int; 2319 enum : DWRITE_SCRIPT_SHAPES 2320 { 2321 /// <summary> 2322 /// No additional shaping requirement. Text is shaped with the writing system default behavior. 2323 /// </summary> 2324 DWRITE_SCRIPT_SHAPES_DEFAULT = 0, 2325 2326 /// <summary> 2327 /// Text should leave no visual on display i.e. control or format control characters. 2328 /// </summary> 2329 DWRITE_SCRIPT_SHAPES_NO_VISUAL = 1 2330 } 2331 /* 2332 #ifdef DEFINE_ENUM_FLAG_OPERATORS 2333 DEFINE_ENUM_FLAG_OPERATORS(DWRITE_SCRIPT_SHAPES); 2334 #endif 2335 */ 2336 2337 /// <summary> 2338 /// Association of text and its writing system script as well as some display attributes. 2339 /// </summary> 2340 struct DWRITE_SCRIPT_ANALYSIS 2341 { 2342 /// <summary> 2343 /// Zero-based index representation of writing system script. 2344 /// </summary> 2345 UINT16 script; 2346 2347 /// <summary> 2348 /// Additional shaping requirement of text. 2349 /// </summary> 2350 DWRITE_SCRIPT_SHAPES shapes; 2351 } 2352 2353 /// <summary> 2354 /// Condition at the edges of inline object or text used to determine 2355 /// line-breaking behavior. 2356 /// </summary> 2357 alias DWRITE_BREAK_CONDITION = int; 2358 enum : DWRITE_BREAK_CONDITION 2359 { 2360 /// <summary> 2361 /// Whether a break is allowed is determined by the condition of the 2362 /// neighboring text span or inline object. 2363 /// </summary> 2364 DWRITE_BREAK_CONDITION_NEUTRAL, 2365 2366 /// <summary> 2367 /// A break is allowed, unless overruled by the condition of the 2368 /// neighboring text span or inline object, either prohibited by a 2369 /// May Not or forced by a Must. 2370 /// </summary> 2371 DWRITE_BREAK_CONDITION_CAN_BREAK, 2372 2373 /// <summary> 2374 /// There should be no break, unless overruled by a Must condition from 2375 /// the neighboring text span or inline object. 2376 /// </summary> 2377 DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 2378 2379 /// <summary> 2380 /// The break must happen, regardless of the condition of the adjacent 2381 /// text span or inline object. 2382 /// </summary> 2383 DWRITE_BREAK_CONDITION_MUST_BREAK 2384 } 2385 2386 /// <summary> 2387 /// Line breakpoint characteristics of a character. 2388 /// </summary> 2389 struct DWRITE_LINE_BREAKPOINT 2390 { 2391 align(1): 2392 union 2393 { 2394 UINT8 data_; 2395 } 2396 // TODO: make helper properties 2397 /* 2398 /// <summary> 2399 /// Breaking condition before the character. 2400 /// </summary> 2401 UINT8 breakConditionBefore : 2; 2402 2403 /// <summary> 2404 /// Breaking condition after the character. 2405 /// </summary> 2406 UINT8 breakConditionAfter : 2; 2407 2408 /// <summary> 2409 /// The character is some form of whitespace, which may be meaningful 2410 /// for justification. 2411 /// </summary> 2412 UINT8 isWhitespace : 1; 2413 2414 /// <summary> 2415 /// The character is a soft hyphen, often used to indicate hyphenation 2416 /// points inside words. 2417 /// </summary> 2418 UINT8 isSoftHyphen : 1; 2419 2420 UINT8 padding : 2; 2421 */ 2422 } 2423 2424 /// <summary> 2425 /// How to apply number substitution on digits and related punctuation. 2426 /// </summary> 2427 alias DWRITE_NUMBER_SUBSTITUTION_METHOD = int; 2428 enum : DWRITE_NUMBER_SUBSTITUTION_METHOD 2429 { 2430 /// <summary> 2431 /// Specifies that the substitution method should be determined based 2432 /// on LOCALE_IDIGITSUBSTITUTION value of the specified text culture. 2433 /// </summary> 2434 DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE, 2435 2436 /// <summary> 2437 /// If the culture is Arabic or Farsi, specifies that the number shape 2438 /// depend on the context. Either traditional or nominal number shape 2439 /// are used depending on the nearest preceding strong character or (if 2440 /// there is none) the reading direction of the paragraph. 2441 /// </summary> 2442 DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL, 2443 2444 /// <summary> 2445 /// Specifies that code points 0x30-0x39 are always rendered as nominal numeral 2446 /// shapes (ones of the European number), i.e., no substitution is performed. 2447 /// </summary> 2448 DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, 2449 2450 /// <summary> 2451 /// Specifies that number are rendered using the national number shape 2452 /// as specified by the LOCALE_SNATIVEDIGITS value of the specified text culture. 2453 /// </summary> 2454 DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL, 2455 2456 /// <summary> 2457 /// Specifies that number are rendered using the traditional shape 2458 /// for the specified culture. For most cultures, this is the same as 2459 /// NativeNational. However, NativeNational results in Latin number 2460 /// for some Arabic cultures, whereas this value results in Arabic 2461 /// number for all Arabic cultures. 2462 /// </summary> 2463 DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL 2464 } 2465 2466 /// <summary> 2467 /// Holds the appropriate digits and numeric punctuation for a given locale. 2468 /// </summary> 2469 mixin( uuid!(IDWriteNumberSubstitution, "14885CC9-BAB0-4f90-B6ED-5C366A2CD03D") ); 2470 interface IDWriteNumberSubstitution : IUnknown 2471 { 2472 extern(Windows): 2473 }; 2474 2475 /// <summary> 2476 /// Shaping output properties per input character. 2477 /// </summary> 2478 struct DWRITE_SHAPING_TEXT_PROPERTIES 2479 { 2480 align(1): 2481 union 2482 { 2483 UINT16 data_; 2484 } 2485 2486 // TODO: make helper proeprties 2487 /* 2488 /// <summary> 2489 /// This character can be shaped independently from the others 2490 /// (usually set for the space character). 2491 /// </summary> 2492 UINT16 isShapedAlone : 1; 2493 2494 /// <summary> 2495 /// Reserved for use by shaping engine. 2496 /// </summary> 2497 UINT16 reserved : 15; 2498 */ 2499 } 2500 2501 /// <summary> 2502 /// Shaping output properties per output glyph. 2503 /// </summary> 2504 struct DWRITE_SHAPING_GLYPH_PROPERTIES 2505 { 2506 align(1): 2507 union 2508 { 2509 UINT16 data_; 2510 } 2511 /* 2512 // TODO: make helper proeprties 2513 /// <summary> 2514 /// Justification class, whether to use spacing, kashidas, or 2515 /// another method. This exists for backwards compatibility 2516 /// with Uniscribe's SCRIPT_JUSTIFY enum. 2517 /// </summary> 2518 UINT16 justification : 4; 2519 2520 /// <summary> 2521 /// Indicates glyph is the first of a cluster. 2522 /// </summary> 2523 UINT16 isClusterStart : 1; 2524 2525 /// <summary> 2526 /// Glyph is a diacritic. 2527 /// </summary> 2528 UINT16 isDiacritic : 1; 2529 2530 /// <summary> 2531 /// Glyph has no width, blank, ZWJ, ZWNJ etc. 2532 /// </summary> 2533 UINT16 isZeroWidthSpace : 1; 2534 2535 /// <summary> 2536 /// Reserved for use by shaping engine. 2537 /// </summary> 2538 UINT16 reserved : 9; 2539 */ 2540 } 2541 2542 /// <summary> 2543 /// The interface implemented by the text analyzer's client to provide text to 2544 /// the analyzer. It allows the separation between the logical view of text as 2545 /// a continuous stream of characters identifiable by unique text positions, 2546 /// and the actual memory layout of potentially discrete blocks of text in the 2547 /// client's backing store. 2548 /// 2549 /// If any of these callbacks returns an error, the analysis functions will 2550 /// stop prematurely and return a callback error. Rather than return E_NOTIMPL, 2551 /// an application should stub the method and return a constant/null and S_OK. 2552 /// </summary> 2553 mixin( uuid!(IDWriteTextAnalysisSource, "688e1a58-5094-47c8-adc8-fbcea60ae92b") ); 2554 interface IDWriteTextAnalysisSource : IUnknown 2555 { 2556 extern(Windows): 2557 /// <summary> 2558 /// Get a block of text starting at the specified text position. 2559 /// Returning NULL indicates the end of text - the position is after 2560 /// the last character. This function is called iteratively for 2561 /// each consecutive block, tying together several fragmented blocks 2562 /// in the backing store into a virtual contiguous string. 2563 /// </summary> 2564 /// <param name="textPosition">First position of the piece to obtain. All 2565 /// positions are in UTF16 code-units, not whole characters, which 2566 /// matters when supplementary characters are used.</param> 2567 /// <param name="textString">Address that receives a pointer to the text block 2568 /// at the specified position.</param> 2569 /// <param name="textLength">Number of UTF16 units of the retrieved chunk. 2570 /// The returned length is not the length of the block, but the length 2571 /// remaining in the block, from the given position until its end. 2572 /// So querying for a position that is 75 positions into a 100 2573 /// position block would return 25.</param> 2574 /// <returns>Pointer to the first character at the given text position. 2575 /// NULL indicates no chunk available at the specified position, either 2576 /// because textPosition >= the entire text content length or because the 2577 /// queried position is not mapped into the app's backing store.</returns> 2578 /// <remarks> 2579 /// Although apps can implement sparse textual content that only maps part of 2580 /// the backing store, the app must map any text that is in the range passed 2581 /// to any analysis functions. 2582 /// </remarks> 2583 HRESULT GetTextAtPosition( 2584 UINT32 textPosition, 2585 /*out*/ const(WCHAR*)* textString, 2586 /*out*/ UINT32* textLength 2587 ); 2588 2589 /// <summary> 2590 /// Get a block of text immediately preceding the specified position. 2591 /// </summary> 2592 /// <param name="textPosition">Position immediately after the last position of the chunk to obtain.</param> 2593 /// <param name="textString">Address that receives a pointer to the text block 2594 /// at the specified position.</param> 2595 /// <param name="textLength">Number of UTF16 units of the retrieved block. 2596 /// The length returned is from the given position to the front of 2597 /// the block.</param> 2598 /// <returns>Pointer to the first character at (textPosition - textLength). 2599 /// NULL indicates no chunk available at the specified position, either 2600 /// because textPosition == 0,the textPosition > the entire text content 2601 /// length, or the queried position is not mapped into the app's backing 2602 /// store.</returns> 2603 /// <remarks> 2604 /// Although apps can implement sparse textual content that only maps part of 2605 /// the backing store, the app must map any text that is in the range passed 2606 /// to any analysis functions. 2607 /// </remarks> 2608 HRESULT GetTextBeforePosition( 2609 UINT32 textPosition, 2610 /*out*/ const(WCHAR*)* textString, 2611 /*out*/ UINT32* textLength 2612 ); 2613 2614 /// <summary> 2615 /// Get paragraph reading direction. 2616 /// </summary> 2617 DWRITE_READING_DIRECTION GetParagraphReadingDirection(); 2618 2619 /// <summary> 2620 /// Get locale name on the range affected by it. 2621 /// </summary> 2622 /// <param name="textPosition">Position to get the locale name of.</param> 2623 /// <param name="textLength">Receives the length from the given position up to the 2624 /// next differing locale.</param> 2625 /// <param name="localeName">Address that receives a pointer to the locale 2626 /// at the specified position.</param> 2627 /// <remarks> 2628 /// The localeName pointer must remain valid until the next call or until 2629 /// the analysis returns. 2630 /// </remarks> 2631 HRESULT GetLocaleName( 2632 UINT32 textPosition, 2633 /*out*/ UINT32* textLength, 2634 /*out*/ const(WCHAR*)* localeName 2635 ); 2636 2637 /// <summary> 2638 /// Get number substitution on the range affected by it. 2639 /// </summary> 2640 /// <param name="textPosition">Position to get the number substitution of.</param> 2641 /// <param name="textLength">Receives the length from the given position up to the 2642 /// next differing number substitution.</param> 2643 /// <param name="numberSubstitution">Address that receives a pointer to the number substitution 2644 /// at the specified position.</param> 2645 /// <remarks> 2646 /// Any implementation should return the number substitution with an 2647 /// incremented ref count, and the analysis will release when finished 2648 /// with it (either before the next call or before it returns). However, 2649 /// the sink callback may hold onto it after that. 2650 /// </remarks> 2651 HRESULT GetNumberSubstitution( 2652 UINT32 textPosition, 2653 /*out*/ UINT32* textLength, 2654 /*out*/ IDWriteNumberSubstitution* numberSubstitution 2655 ); 2656 } 2657 2658 /// <summary> 2659 /// The interface implemented by the text analyzer's client to receive the 2660 /// output of a given text analysis. The Text analyzer disregards any current 2661 /// state of the analysis sink, therefore a Set method call on a range 2662 /// overwrites the previously set analysis result of the same range. 2663 /// </summary> 2664 mixin( uuid!(IDWriteTextAnalysisSink, "5810cd44-0ca0-4701-b3fa-bec5182ae4f6") ); 2665 interface IDWriteTextAnalysisSink : IUnknown 2666 { 2667 extern(Windows): 2668 /// <summary> 2669 /// Report script analysis for the text range. 2670 /// </summary> 2671 /// <param name="textPosition">Starting position to report from.</param> 2672 /// <param name="textLength">Number of UTF16 units of the reported range.</param> 2673 /// <param name="scriptAnalysis">Script analysis of characters in range.</param> 2674 /// <returns> 2675 /// A successful code or error code to abort analysis. 2676 /// </returns> 2677 HRESULT SetScriptAnalysis( 2678 UINT32 textPosition, 2679 UINT32 textLength, 2680 const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis 2681 ); 2682 2683 /// <summary> 2684 /// Report line-break opportunities for each character, starting from 2685 /// the specified position. 2686 /// </summary> 2687 /// <param name="textPosition">Starting position to report from.</param> 2688 /// <param name="textLength">Number of UTF16 units of the reported range.</param> 2689 /// <param name="lineBreakpoints">Breaking conditions for each character.</param> 2690 /// <returns> 2691 /// A successful code or error code to abort analysis. 2692 /// </returns> 2693 HRESULT SetLineBreakpoints( 2694 UINT32 textPosition, 2695 UINT32 textLength, 2696 const(DWRITE_LINE_BREAKPOINT)* lineBreakpoints 2697 ); 2698 2699 /// <summary> 2700 /// Set bidirectional level on the range, called once per each 2701 /// level run change (either explicit or resolved implicit). 2702 /// </summary> 2703 /// <param name="textPosition">Starting position to report from.</param> 2704 /// <param name="textLength">Number of UTF16 units of the reported range.</param> 2705 /// <param name="explicitLevel">Explicit level from embedded control codes 2706 /// RLE/RLO/LRE/LRO/PDF, determined before any additional rules.</param> 2707 /// <param name="resolvedLevel">Final implicit level considering the 2708 /// explicit level and characters' natural directionality, after all 2709 /// Bidi rules have been applied.</param> 2710 /// <returns> 2711 /// A successful code or error code to abort analysis. 2712 /// </returns> 2713 HRESULT SetBidiLevel( 2714 UINT32 textPosition, 2715 UINT32 textLength, 2716 UINT8 explicitLevel, 2717 UINT8 resolvedLevel 2718 ); 2719 2720 /// <summary> 2721 /// Set number substitution on the range. 2722 /// </summary> 2723 /// <param name="textPosition">Starting position to report from.</param> 2724 /// <param name="textLength">Number of UTF16 units of the reported range.</param> 2725 /// <param name="numberSubstitution">The number substitution applicable to 2726 /// the returned range of text. The sink callback may hold onto it by 2727 /// incrementing its ref count.</param> 2728 /// <returns> 2729 /// A successful code or error code to abort analysis. 2730 /// </returns> 2731 /// <remark> 2732 /// Unlike script and bidi analysis, where every character passed to the 2733 /// analyzer has a result, this will only be called for those ranges where 2734 /// substitution is applicable. For any other range, you will simply not 2735 /// be called. 2736 /// </remark> 2737 HRESULT SetNumberSubstitution( 2738 UINT32 textPosition, 2739 UINT32 textLength, 2740 IDWriteNumberSubstitution numberSubstitution 2741 ); 2742 } 2743 2744 /// <summary> 2745 /// Analyzes various text properties for complex script processing. 2746 /// </summary> 2747 mixin( uuid!(IDWriteTextAnalyzer, "b7e6163e-7f46-43b4-84b3-e4e6249c365d") ); 2748 interface IDWriteTextAnalyzer : IUnknown 2749 { 2750 extern(Windows): 2751 /// <summary> 2752 /// Analyzes a text range for script boundaries, reading text attributes 2753 /// from the source and reporting the Unicode script ID to the sink 2754 /// callback SetScript. 2755 /// </summary> 2756 /// <param name="analysisSource">Source object to analyze.</param> 2757 /// <param name="textPosition">Starting position within the source object.</param> 2758 /// <param name="textLength">Length to analyze.</param> 2759 /// <param name="analysisSink">Callback object.</param> 2760 /// <returns> 2761 /// Standard HRESULT error code. 2762 /// </returns> 2763 HRESULT AnalyzeScript( 2764 IDWriteTextAnalysisSource analysisSource, 2765 UINT32 textPosition, 2766 UINT32 textLength, 2767 IDWriteTextAnalysisSink analysisSink 2768 ); 2769 2770 /// <summary> 2771 /// Analyzes a text range for script directionality, reading attributes 2772 /// from the source and reporting levels to the sink callback SetBidiLevel. 2773 /// </summary> 2774 /// <param name="analysisSource">Source object to analyze.</param> 2775 /// <param name="textPosition">Starting position within the source object.</param> 2776 /// <param name="textLength">Length to analyze.</param> 2777 /// <param name="analysisSink">Callback object.</param> 2778 /// <returns> 2779 /// Standard HRESULT error code. 2780 /// </returns> 2781 /// <remarks> 2782 /// While the function can handle multiple paragraphs, the text range 2783 /// should not arbitrarily split the middle of paragraphs. Otherwise the 2784 /// returned levels may be wrong, since the Bidi algorithm is meant to 2785 /// apply to the paragraph as a whole. 2786 /// </remarks> 2787 /// <remarks> 2788 /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account. 2789 /// </remarks> 2790 HRESULT AnalyzeBidi( 2791 IDWriteTextAnalysisSource analysisSource, 2792 UINT32 textPosition, 2793 UINT32 textLength, 2794 IDWriteTextAnalysisSink analysisSink 2795 ); 2796 2797 /// <summary> 2798 /// Analyzes a text range for spans where number substitution is applicable, 2799 /// reading attributes from the source and reporting substitutable ranges 2800 /// to the sink callback SetNumberSubstitution. 2801 /// </summary> 2802 /// <param name="analysisSource">Source object to analyze.</param> 2803 /// <param name="textPosition">Starting position within the source object.</param> 2804 /// <param name="textLength">Length to analyze.</param> 2805 /// <param name="analysisSink">Callback object.</param> 2806 /// <returns> 2807 /// Standard HRESULT error code. 2808 /// </returns> 2809 /// <remarks> 2810 /// While the function can handle multiple ranges of differing number 2811 /// substitutions, the text ranges should not arbitrarily split the 2812 /// middle of numbers. Otherwise it will treat the numbers separately 2813 /// and will not translate any intervening punctuation. 2814 /// </remarks> 2815 /// <remarks> 2816 /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account. 2817 /// </remarks> 2818 HRESULT AnalyzeNumberSubstitution( 2819 IDWriteTextAnalysisSource analysisSource, 2820 UINT32 textPosition, 2821 UINT32 textLength, 2822 IDWriteTextAnalysisSink analysisSink 2823 ); 2824 2825 /// <summary> 2826 /// Analyzes a text range for potential breakpoint opportunities, reading 2827 /// attributes from the source and reporting breakpoint opportunities to 2828 /// the sink callback SetLineBreakpoints. 2829 /// </summary> 2830 /// <param name="analysisSource">Source object to analyze.</param> 2831 /// <param name="textPosition">Starting position within the source object.</param> 2832 /// <param name="textLength">Length to analyze.</param> 2833 /// <param name="analysisSink">Callback object.</param> 2834 /// <returns> 2835 /// Standard HRESULT error code. 2836 /// </returns> 2837 /// <remarks> 2838 /// While the function can handle multiple paragraphs, the text range 2839 /// should not arbitrarily split the middle of paragraphs, unless the 2840 /// given text span is considered a whole unit. Otherwise the 2841 /// returned properties for the first and last characters will 2842 /// inappropriately allow breaks. 2843 /// </remarks> 2844 /// <remarks> 2845 /// Special cases include the first, last, and surrogate characters. Any 2846 /// text span is treated as if adjacent to inline objects on either side. 2847 /// So the rules with contingent-break opportunities are used, where the 2848 /// edge between text and inline objects is always treated as a potential 2849 /// break opportunity, dependent on any overriding rules of the adjacent 2850 /// objects to prohibit or force the break (see Unicode TR #14). 2851 /// Surrogate pairs never break between. 2852 /// </remarks> 2853 HRESULT AnalyzeLineBreakpoints( 2854 IDWriteTextAnalysisSource analysisSource, 2855 UINT32 textPosition, 2856 UINT32 textLength, 2857 IDWriteTextAnalysisSink analysisSink 2858 ); 2859 2860 /// <summary> 2861 /// Parses the input text string and maps it to the set of glyphs and associated glyph data 2862 /// according to the font and the writing system's rendering rules. 2863 /// </summary> 2864 /// <param name="textString">The string to convert to glyphs.</param> 2865 /// <param name="textLength">The length of textString.</param> 2866 /// <param name="fontFace">The font face to get glyphs from.</param> 2867 /// <param name="isSideways">Set to true if the text is intended to be 2868 /// drawn vertically.</param> 2869 /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> 2870 /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> 2871 /// <param name="localeName">The locale to use when selecting glyphs. 2872 /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs. 2873 /// If this is NULL then the default mapping based on the script is used.</param> 2874 /// <param name="numberSubstitution">Optional number substitution which 2875 /// selects the appropriate glyphs for digits and related numeric characters, 2876 /// depending on the results obtained from AnalyzeNumberSubstitution. Passing 2877 /// null indicates that no substitution is needed and that the digits should 2878 /// receive nominal glyphs.</param> 2879 /// <param name="features">An array of pointers to the sets of typographic 2880 /// features to use in each feature range.</param> 2881 /// <param name="featureRangeLengths">The length of each feature range, in characters. 2882 /// The sum of all lengths should be equal to textLength.</param> 2883 /// <param name="featureRanges">The number of feature ranges.</param> 2884 /// <param name="maxGlyphCount">The maximum number of glyphs that can be 2885 /// returned.</param> 2886 /// <param name="clusterMap">The mapping from character ranges to glyph 2887 /// ranges.</param> 2888 /// <param name="textProps">Per-character output properties.</param> 2889 /// <param name="glyphIndices">Output glyph indices.</param> 2890 /// <param name="glyphProps">Per-glyph output properties.</param> 2891 /// <param name="actualGlyphCount">The actual number of glyphs returned if 2892 /// the call succeeds.</param> 2893 /// <returns> 2894 /// Standard HRESULT error code. 2895 /// </returns> 2896 /// <remarks> 2897 /// Note that the mapping from characters to glyphs is, in general, many- 2898 /// to-many. The recommended estimate for the per-glyph output buffers is 2899 /// (3 * textLength / 2 + 16). This is not guaranteed to be sufficient. 2900 /// 2901 /// The value of the actualGlyphCount parameter is only valid if the call 2902 /// succeeds. In the event that maxGlyphCount is not big enough 2903 /// E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), 2904 /// will be returned. The application should allocate a larger buffer and try again. 2905 /// </remarks> 2906 HRESULT GetGlyphs( 2907 const(WCHAR)* textString, 2908 UINT32 textLength, 2909 IDWriteFontFace fontFace, 2910 BOOL isSideways, 2911 BOOL isRightToLeft, 2912 const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, 2913 const(WCHAR)* localeName, 2914 IDWriteNumberSubstitution numberSubstitution, 2915 const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, 2916 const(UINT32)* featureRangeLengths, 2917 UINT32 featureRanges, 2918 UINT32 maxGlyphCount, 2919 /*out*/ UINT16* clusterMap, 2920 /*out*/ DWRITE_SHAPING_TEXT_PROPERTIES* textProps, 2921 /*out*/ UINT16* glyphIndices, 2922 /*out*/ DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps, 2923 /*out*/ UINT32* actualGlyphCount 2924 ); 2925 2926 /// <summary> 2927 /// Place glyphs output from the GetGlyphs method according to the font 2928 /// and the writing system's rendering rules. 2929 /// </summary> 2930 /// <param name="textString">The original string the glyphs came from.</param> 2931 /// <param name="clusterMap">The mapping from character ranges to glyph 2932 /// ranges. Returned by GetGlyphs.</param> 2933 /// <param name="textProps">Per-character properties. Returned by 2934 /// GetGlyphs.</param> 2935 /// <param name="textLength">The length of textString.</param> 2936 /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param> 2937 /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param> 2938 /// <param name="glyphCount">The number of glyphs.</param> 2939 /// <param name="fontFace">The font face the glyphs came from.</param> 2940 /// <param name="fontEmSize">Logical font size in DIP's.</param> 2941 /// <param name="isSideways">Set to true if the text is intended to be 2942 /// drawn vertically.</param> 2943 /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> 2944 /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> 2945 /// <param name="localeName">The locale to use when selecting glyphs. 2946 /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs. 2947 /// If this is NULL then the default mapping based on the script is used.</param> 2948 /// <param name="features">An array of pointers to the sets of typographic 2949 /// features to use in each feature range.</param> 2950 /// <param name="featureRangeLengths">The length of each feature range, in characters. 2951 /// The sum of all lengths should be equal to textLength.</param> 2952 /// <param name="featureRanges">The number of feature ranges.</param> 2953 /// <param name="glyphAdvances">The advance width of each glyph.</param> 2954 /// <param name="glyphOffsets">The offset of the origin of each glyph.</param> 2955 /// <returns> 2956 /// Standard HRESULT error code. 2957 /// </returns> 2958 HRESULT GetGlyphPlacements( 2959 const(WCHAR)* textString, 2960 const(UINT16)* clusterMap, 2961 DWRITE_SHAPING_TEXT_PROPERTIES* textProps, 2962 UINT32 textLength, 2963 const(UINT16)* glyphIndices, 2964 const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProps, 2965 UINT32 glyphCount, 2966 IDWriteFontFace fontFace, 2967 FLOAT fontEmSize, 2968 BOOL isSideways, 2969 BOOL isRightToLeft, 2970 const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, 2971 const(WCHAR)* localeName, 2972 const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, 2973 const(UINT32)* featureRangeLengths, 2974 UINT32 featureRanges, 2975 /*out*/ FLOAT* glyphAdvances, 2976 /*out*/ DWRITE_GLYPH_OFFSET* glyphOffsets 2977 ); 2978 2979 /// <summary> 2980 /// Place glyphs output from the GetGlyphs method according to the font 2981 /// and the writing system's rendering rules. 2982 /// </summary> 2983 /// <param name="textString">The original string the glyphs came from.</param> 2984 /// <param name="clusterMap">The mapping from character ranges to glyph 2985 /// ranges. Returned by GetGlyphs.</param> 2986 /// <param name="textProps">Per-character properties. Returned by 2987 /// GetGlyphs.</param> 2988 /// <param name="textLength">The length of textString.</param> 2989 /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param> 2990 /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param> 2991 /// <param name="glyphCount">The number of glyphs.</param> 2992 /// <param name="fontFace">The font face the glyphs came from.</param> 2993 /// <param name="fontEmSize">Logical font size in DIP's.</param> 2994 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this 2995 /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param> 2996 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 2997 /// scaling specified by the font size and pixelsPerDip.</param> 2998 /// <param name="useGdiNatural"> 2999 /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text. 3000 /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font 3001 /// created with CLEARTYPE_NATURAL_QUALITY. 3002 /// </param> 3003 /// <param name="isSideways">Set to true if the text is intended to be 3004 /// drawn vertically.</param> 3005 /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> 3006 /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> 3007 /// <param name="localeName">The locale to use when selecting glyphs. 3008 /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs. 3009 /// If this is NULL then the default mapping based on the script is used.</param> 3010 /// <param name="features">An array of pointers to the sets of typographic 3011 /// features to use in each feature range.</param> 3012 /// <param name="featureRangeLengths">The length of each feature range, in characters. 3013 /// The sum of all lengths should be equal to textLength.</param> 3014 /// <param name="featureRanges">The number of feature ranges.</param> 3015 /// <param name="glyphAdvances">The advance width of each glyph.</param> 3016 /// <param name="glyphOffsets">The offset of the origin of each glyph.</param> 3017 /// <returns> 3018 /// Standard HRESULT error code. 3019 /// </returns> 3020 HRESULT GetGdiCompatibleGlyphPlacements( 3021 const(WCHAR)* textString, 3022 const(UINT16)* clusterMap, 3023 DWRITE_SHAPING_TEXT_PROPERTIES* textProps, 3024 UINT32 textLength, 3025 const(UINT16)* glyphIndices, 3026 const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProps, 3027 UINT32 glyphCount, 3028 IDWriteFontFace fontFace, 3029 FLOAT fontEmSize, 3030 FLOAT pixelsPerDip, 3031 const(DWRITE_MATRIX)* transform, 3032 BOOL useGdiNatural, 3033 BOOL isSideways, 3034 BOOL isRightToLeft, 3035 const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, 3036 const(WCHAR)* localeName, 3037 const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, 3038 const(UINT32)* featureRangeLengths, 3039 UINT32 featureRanges, 3040 /*out*/ FLOAT* glyphAdvances, 3041 /*out*/ DWRITE_GLYPH_OFFSET* glyphOffsets 3042 ); 3043 } 3044 3045 /// <summary> 3046 /// The DWRITE_GLYPH_RUN structure contains the information needed by renderers 3047 /// to draw glyph runs. All coordinates are in device independent pixels (DIPs). 3048 /// </summary> 3049 struct DWRITE_GLYPH_RUN 3050 { 3051 /// <summary> 3052 /// The physical font face to draw with. 3053 /// </summary> 3054 IDWriteFontFace fontFace; 3055 3056 /// <summary> 3057 /// Logical size of the font in DIPs, not points (equals 1/96 inch). 3058 /// </summary> 3059 FLOAT fontEmSize; 3060 3061 /// <summary> 3062 /// The number of glyphs. 3063 /// </summary> 3064 UINT32 glyphCount; 3065 3066 /// <summary> 3067 /// The indices to render. 3068 /// </summary> 3069 const(UINT16)* glyphIndices; 3070 3071 /// <summary> 3072 /// Glyph advance widths. 3073 /// </summary> 3074 const(FLOAT)* glyphAdvances; 3075 3076 /// <summary> 3077 /// Glyph offsets. 3078 /// </summary> 3079 const(DWRITE_GLYPH_OFFSET)* glyphOffsets; 3080 3081 /// <summary> 3082 /// If true, specifies that glyphs are rotated 90 degrees to the left and 3083 /// vertical metrics are used. Vertical writing is achieved by specifying 3084 /// isSideways = true and rotating the entire run 90 degrees to the right 3085 /// via a rotate transform. 3086 /// </summary> 3087 BOOL isSideways; 3088 3089 /// <summary> 3090 /// The implicit resolved bidi level of the run. Odd levels indicate 3091 /// right-to-left languages like Hebrew and Arabic, while even levels 3092 /// indicate left-to-right languages like English and Japanese (when 3093 /// written horizontally). For right-to-left languages, the text origin 3094 /// is on the right, and text should be drawn to the left. 3095 /// </summary> 3096 UINT32 bidiLevel; 3097 } 3098 3099 /// <summary> 3100 /// The DWRITE_GLYPH_RUN_DESCRIPTION structure contains additional properties 3101 /// related to those in DWRITE_GLYPH_RUN. 3102 /// </summary> 3103 struct DWRITE_GLYPH_RUN_DESCRIPTION 3104 { 3105 /// <summary> 3106 /// The locale name associated with this run. 3107 /// </summary> 3108 const(WCHAR)* localeName; 3109 3110 /// <summary> 3111 /// The text associated with the glyphs. 3112 /// </summary> 3113 const(WCHAR)* string; 3114 3115 /// <summary> 3116 /// The number of characters (UTF16 code-units). 3117 /// Note that this may be different than the number of glyphs. 3118 /// </summary> 3119 UINT32 stringLength; 3120 3121 /// <summary> 3122 /// An array of indices to the glyph indices array, of the first glyphs of 3123 /// all the glyph clusters of the glyphs to render. 3124 /// </summary> 3125 const(UINT16)* clusterMap; 3126 3127 /// <summary> 3128 /// Corresponding text position in the original string 3129 /// this glyph run came from. 3130 /// </summary> 3131 UINT32 textPosition; 3132 } 3133 3134 /// <summary> 3135 /// The DWRITE_UNDERLINE structure contains information about the size and 3136 /// placement of underlines. All coordinates are in device independent 3137 /// pixels (DIPs). 3138 /// </summary> 3139 struct DWRITE_UNDERLINE 3140 { 3141 /// <summary> 3142 /// Width of the underline, measured parallel to the baseline. 3143 /// </summary> 3144 FLOAT width; 3145 3146 /// <summary> 3147 /// Thickness of the underline, measured perpendicular to the 3148 /// baseline. 3149 /// </summary> 3150 FLOAT thickness; 3151 3152 /// <summary> 3153 /// Offset of the underline from the baseline. 3154 /// A positive offset represents a position below the baseline and 3155 /// a negative offset is above. 3156 /// </summary> 3157 FLOAT offset; 3158 3159 /// <summary> 3160 /// Height of the tallest run where the underline applies. 3161 /// </summary> 3162 FLOAT runHeight; 3163 3164 /// <summary> 3165 /// Reading direction of the text associated with the underline. This 3166 /// value is used to interpret whether the width value runs horizontally 3167 /// or vertically. 3168 /// </summary> 3169 DWRITE_READING_DIRECTION readingDirection; 3170 3171 /// <summary> 3172 /// Flow direction of the text associated with the underline. This value 3173 /// is used to interpret whether the thickness value advances top to 3174 /// bottom, left to right, or right to left. 3175 /// </summary> 3176 DWRITE_FLOW_DIRECTION flowDirection; 3177 3178 /// <summary> 3179 /// Locale of the text the underline is being drawn under. Can be 3180 /// pertinent where the locale affects how the underline is drawn. 3181 /// For example, in vertical text, the underline belongs on the 3182 /// left for Chinese but on the right for Japanese. 3183 /// This choice is completely left up to higher levels. 3184 /// </summary> 3185 const(WCHAR)* localeName; 3186 3187 /// <summary> 3188 /// The measuring mode can be useful to the renderer to determine how 3189 /// underlines are rendered, e.g. rounding the thickness to a whole pixel 3190 /// in GDI-compatible modes. 3191 /// </summary> 3192 DWRITE_MEASURING_MODE measuringMode; 3193 } 3194 3195 /// <summary> 3196 /// The DWRITE_STRIKETHROUGH structure contains information about the size and 3197 /// placement of strikethroughs. All coordinates are in device independent 3198 /// pixels (DIPs). 3199 /// </summary> 3200 struct DWRITE_STRIKETHROUGH 3201 { 3202 /// <summary> 3203 /// Width of the strikethrough, measured parallel to the baseline. 3204 /// </summary> 3205 FLOAT width; 3206 3207 /// <summary> 3208 /// Thickness of the strikethrough, measured perpendicular to the 3209 /// baseline. 3210 /// </summary> 3211 FLOAT thickness; 3212 3213 /// <summary> 3214 /// Offset of the strikethrough from the baseline. 3215 /// A positive offset represents a position below the baseline and 3216 /// a negative offset is above. 3217 /// </summary> 3218 FLOAT offset; 3219 3220 /// <summary> 3221 /// Reading direction of the text associated with the strikethrough. This 3222 /// value is used to interpret whether the width value runs horizontally 3223 /// or vertically. 3224 /// </summary> 3225 DWRITE_READING_DIRECTION readingDirection; 3226 3227 /// <summary> 3228 /// Flow direction of the text associated with the strikethrough. This 3229 /// value is used to interpret whether the thickness value advances top to 3230 /// bottom, left to right, or right to left. 3231 /// </summary> 3232 DWRITE_FLOW_DIRECTION flowDirection; 3233 3234 /// <summary> 3235 /// Locale of the range. Can be pertinent where the locale affects the style. 3236 /// </summary> 3237 const(WCHAR)* localeName; 3238 3239 /// <summary> 3240 /// The measuring mode can be useful to the renderer to determine how 3241 /// underlines are rendered, e.g. rounding the thickness to a whole pixel 3242 /// in GDI-compatible modes. 3243 /// </summary> 3244 DWRITE_MEASURING_MODE measuringMode; 3245 } 3246 3247 /// <summary> 3248 /// The DWRITE_LINE_METRICS structure contains information about a formatted 3249 /// line of text. 3250 /// </summary> 3251 struct DWRITE_LINE_METRICS 3252 { 3253 /// <summary> 3254 /// The number of total text positions in the line. 3255 /// This includes any trailing whitespace and newline characters. 3256 /// </summary> 3257 UINT32 length; 3258 3259 /// <summary> 3260 /// The number of whitespace positions at the end of the line. Newline 3261 /// sequences are considered whitespace. 3262 /// </summary> 3263 UINT32 trailingWhitespaceLength; 3264 3265 /// <summary> 3266 /// The number of characters in the newline sequence at the end of the line. 3267 /// If the count is zero, then the line was either wrapped or it is the 3268 /// end of the text. 3269 /// </summary> 3270 UINT32 newlineLength; 3271 3272 /// <summary> 3273 /// Height of the line as measured from top to bottom. 3274 /// </summary> 3275 FLOAT height; 3276 3277 /// <summary> 3278 /// Distance from the top of the line to its baseline. 3279 /// </summary> 3280 FLOAT baseline; 3281 3282 /// <summary> 3283 /// The line is trimmed. 3284 /// </summary> 3285 BOOL isTrimmed; 3286 } 3287 3288 3289 /// <summary> 3290 /// The DWRITE_CLUSTER_METRICS structure contains information about a glyph cluster. 3291 /// </summary> 3292 struct DWRITE_CLUSTER_METRICS 3293 { 3294 align(1): 3295 /// <summary> 3296 /// The total advance width of all glyphs in the cluster. 3297 /// </summary> 3298 FLOAT width; 3299 3300 /// <summary> 3301 /// The number of text positions in the cluster. 3302 /// </summary> 3303 UINT16 length; 3304 3305 union 3306 { 3307 UINT16 data_; 3308 } 3309 /* 3310 // TODO: make helper proeprties 3311 /// <summary> 3312 /// Indicate whether line can be broken right after the cluster. 3313 /// </summary> 3314 UINT16 canWrapLineAfter : 1; 3315 3316 /// <summary> 3317 /// Indicate whether the cluster corresponds to whitespace character. 3318 /// </summary> 3319 UINT16 isWhitespace : 1; 3320 3321 /// <summary> 3322 /// Indicate whether the cluster corresponds to a newline character. 3323 /// </summary> 3324 UINT16 isNewline : 1; 3325 3326 /// <summary> 3327 /// Indicate whether the cluster corresponds to soft hyphen character. 3328 /// </summary> 3329 UINT16 isSoftHyphen : 1; 3330 3331 /// <summary> 3332 /// Indicate whether the cluster is read from right to left. 3333 /// </summary> 3334 UINT16 isRightToLeft : 1; 3335 3336 UINT16 padding : 11; 3337 */ 3338 } 3339 3340 3341 /// <summary> 3342 /// Overall metrics associated with text after layout. 3343 /// All coordinates are in device independent pixels (DIPs). 3344 /// </summary> 3345 struct DWRITE_TEXT_METRICS 3346 { 3347 /// <summary> 3348 /// Left-most point of formatted text relative to layout box 3349 /// (excluding any glyph overhang). 3350 /// </summary> 3351 FLOAT left; 3352 3353 /// <summary> 3354 /// Top-most point of formatted text relative to layout box 3355 /// (excluding any glyph overhang). 3356 /// </summary> 3357 FLOAT top; 3358 3359 /// <summary> 3360 /// The width of the formatted text ignoring trailing whitespace 3361 /// at the end of each line. 3362 /// </summary> 3363 FLOAT width; 3364 3365 /// <summary> 3366 /// The width of the formatted text taking into account the 3367 /// trailing whitespace at the end of each line. 3368 /// </summary> 3369 FLOAT widthIncludingTrailingWhitespace; 3370 3371 /// <summary> 3372 /// The height of the formatted text. The height of an empty string 3373 /// is determined by the size of the default font's line height. 3374 /// </summary> 3375 FLOAT height; 3376 3377 /// <summary> 3378 /// Initial width given to the layout. Depending on whether the text 3379 /// was wrapped or not, it can be either larger or smaller than the 3380 /// text content width. 3381 /// </summary> 3382 FLOAT layoutWidth; 3383 3384 /// <summary> 3385 /// Initial height given to the layout. Depending on the length of the 3386 /// text, it may be larger or smaller than the text content height. 3387 /// </summary> 3388 FLOAT layoutHeight; 3389 3390 /// <summary> 3391 /// The maximum reordering count of any line of text, used 3392 /// to calculate the most number of hit-testing boxes needed. 3393 /// If the layout has no bidirectional text or no text at all, 3394 /// the minimum level is 1. 3395 /// </summary> 3396 UINT32 maxBidiReorderingDepth; 3397 3398 /// <summary> 3399 /// Total number of lines. 3400 /// </summary> 3401 UINT32 lineCount; 3402 } 3403 3404 3405 /// <summary> 3406 /// Properties describing the geometric measurement of an 3407 /// application-defined inline object. 3408 /// </summary> 3409 struct DWRITE_INLINE_OBJECT_METRICS 3410 { 3411 /// <summary> 3412 /// Width of the inline object. 3413 /// </summary> 3414 FLOAT width; 3415 3416 /// <summary> 3417 /// Height of the inline object as measured from top to bottom. 3418 /// </summary> 3419 FLOAT height; 3420 3421 /// <summary> 3422 /// Distance from the top of the object to the baseline where it is lined up with the adjacent text. 3423 /// If the baseline is at the bottom, baseline simply equals height. 3424 /// </summary> 3425 FLOAT baseline; 3426 3427 /// <summary> 3428 /// Flag indicating whether the object is to be placed upright or alongside the text baseline 3429 /// for vertical text. 3430 /// </summary> 3431 BOOL supportsSideways; 3432 } 3433 3434 3435 /// <summary> 3436 /// The DWRITE_OVERHANG_METRICS structure holds how much any visible pixels 3437 /// (in DIPs) overshoot each side of the layout or inline objects. 3438 /// </summary> 3439 /// <remarks> 3440 /// Positive overhangs indicate that the visible area extends outside the layout 3441 /// box or inline object, while negative values mean there is whitespace inside. 3442 /// The returned values are unaffected by rendering transforms or pixel snapping. 3443 /// Additionally, they may not exactly match final target's pixel bounds after 3444 /// applying grid fitting and hinting. 3445 /// </remarks> 3446 struct DWRITE_OVERHANG_METRICS 3447 { 3448 /// <summary> 3449 /// The distance from the left-most visible DIP to its left alignment edge. 3450 /// </summary> 3451 FLOAT left; 3452 3453 /// <summary> 3454 /// The distance from the top-most visible DIP to its top alignment edge. 3455 /// </summary> 3456 FLOAT top; 3457 3458 /// <summary> 3459 /// The distance from the right-most visible DIP to its right alignment edge. 3460 /// </summary> 3461 FLOAT right; 3462 3463 /// <summary> 3464 /// The distance from the bottom-most visible DIP to its bottom alignment edge. 3465 /// </summary> 3466 FLOAT bottom; 3467 } 3468 3469 3470 /// <summary> 3471 /// Geometry enclosing of text positions. 3472 /// </summary> 3473 struct DWRITE_HIT_TEST_METRICS 3474 { 3475 /// <summary> 3476 /// First text position within the geometry. 3477 /// </summary> 3478 UINT32 textPosition; 3479 3480 /// <summary> 3481 /// Number of text positions within the geometry. 3482 /// </summary> 3483 UINT32 length; 3484 3485 /// <summary> 3486 /// Left position of the top-left coordinate of the geometry. 3487 /// </summary> 3488 FLOAT left; 3489 3490 /// <summary> 3491 /// Top position of the top-left coordinate of the geometry. 3492 /// </summary> 3493 FLOAT top; 3494 3495 /// <summary> 3496 /// Geometry's width. 3497 /// </summary> 3498 FLOAT width; 3499 3500 /// <summary> 3501 /// Geometry's height. 3502 /// </summary> 3503 FLOAT height; 3504 3505 /// <summary> 3506 /// Bidi level of text positions enclosed within the geometry. 3507 /// </summary> 3508 UINT32 bidiLevel; 3509 3510 /// <summary> 3511 /// Geometry encloses text? 3512 /// </summary> 3513 BOOL isText; 3514 3515 /// <summary> 3516 /// Range is trimmed. 3517 /// </summary> 3518 BOOL isTrimmed; 3519 } 3520 3521 3522 3523 /// <summary> 3524 /// The IDWriteInlineObject interface wraps an application defined inline graphic, 3525 /// allowing DWrite to query metrics as if it was a glyph inline with the text. 3526 /// </summary> 3527 mixin( uuid!(IDWriteInlineObject, "8339FDE3-106F-47ab-8373-1C6295EB10B3") ); 3528 interface IDWriteInlineObject : IUnknown 3529 { 3530 extern(Windows): 3531 /// <summary> 3532 /// The application implemented rendering callback (IDWriteTextRenderer::DrawInlineObject) 3533 /// can use this to draw the inline object without needing to cast or query the object 3534 /// type. The text layout does not call this method directly. 3535 /// </summary> 3536 /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param> 3537 /// <param name="renderer">The renderer passed to IDWriteTextLayout::Draw as the object's containing parent.</param> 3538 /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param> 3539 /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param> 3540 /// <param name="isSideways">The object should be drawn on its side.</param> 3541 /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param> 3542 /// <param name="clientDrawingEffect">The drawing effect set in IDWriteTextLayout::SetDrawingEffect.</param> 3543 /// <returns> 3544 /// Standard HRESULT error code. 3545 /// </returns> 3546 HRESULT Draw( 3547 void* clientDrawingContext, 3548 IDWriteTextRenderer renderer, 3549 FLOAT originX, 3550 FLOAT originY, 3551 BOOL isSideways, 3552 BOOL isRightToLeft, 3553 IUnknown clientDrawingEffect 3554 ); 3555 3556 /// <summary> 3557 /// TextLayout calls this callback function to get the measurement of the inline object. 3558 /// </summary> 3559 /// <param name="metrics">Returned metrics</param> 3560 /// <returns> 3561 /// Standard HRESULT error code. 3562 /// </returns> 3563 HRESULT GetMetrics( 3564 /*out*/ DWRITE_INLINE_OBJECT_METRICS* metrics 3565 ); 3566 3567 /// <summary> 3568 /// TextLayout calls this callback function to get the visible extents (in DIPs) of the inline object. 3569 /// In the case of a simple bitmap, with no padding and no overhang, all the overhangs will 3570 /// simply be zeroes. 3571 /// </summary> 3572 /// <param name="overhangs">Overshoot of visible extents (in DIPs) outside the object.</param> 3573 /// <returns> 3574 /// Standard HRESULT error code. 3575 /// </returns> 3576 /// <remarks> 3577 /// The overhangs should be returned relative to the reported size of the object 3578 /// (DWRITE_INLINE_OBJECT_METRICS::width/height), and should not be baseline 3579 /// adjusted. If you have an image that is actually 100x100 DIPs, but you want it 3580 /// slightly inset (perhaps it has a glow) by 20 DIPs on each side, you would 3581 /// return a width/height of 60x60 and four overhangs of 20 DIPs. 3582 /// </remarks> 3583 HRESULT GetOverhangMetrics( 3584 /*out*/ DWRITE_OVERHANG_METRICS* overhangs 3585 ); 3586 3587 /// <summary> 3588 /// Layout uses this to determine the line breaking behavior of the inline object 3589 /// amidst the text. 3590 /// </summary> 3591 /// <param name="breakConditionBefore">Line-breaking condition between the object and the content immediately preceding it.</param> 3592 /// <param name="breakConditionAfter" >Line-breaking condition between the object and the content immediately following it.</param> 3593 /// <returns> 3594 /// Standard HRESULT error code. 3595 /// </returns> 3596 HRESULT GetBreakConditions( 3597 /*out*/ DWRITE_BREAK_CONDITION* breakConditionBefore, 3598 /*out*/ DWRITE_BREAK_CONDITION* breakConditionAfter 3599 ); 3600 } 3601 3602 /// <summary> 3603 /// The IDWritePixelSnapping interface defines the pixel snapping properties of a text renderer. 3604 /// </summary> 3605 mixin( uuid!(IDWritePixelSnapping, "eaf3a2da-ecf4-4d24-b644-b34f6842024b") ); 3606 interface IDWritePixelSnapping : IUnknown 3607 { 3608 extern(Windows): 3609 /// <summary> 3610 /// Determines whether pixel snapping is disabled. The recommended default is FALSE, 3611 /// unless doing animation that requires subpixel vertical placement. 3612 /// </summary> 3613 /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param> 3614 /// <param name="isDisabled">Receives TRUE if pixel snapping is disabled or FALSE if it not.</param> 3615 /// <returns> 3616 /// Standard HRESULT error code. 3617 /// </returns> 3618 HRESULT IsPixelSnappingDisabled( 3619 void* clientDrawingContext, 3620 /*out*/ BOOL* isDisabled 3621 ); 3622 3623 /// <summary> 3624 /// Gets the current transform that maps abstract coordinates to DIPs, 3625 /// which may disable pixel snapping upon any rotation or shear. 3626 /// </summary> 3627 /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param> 3628 /// <param name="transform">Receives the transform.</param> 3629 /// <returns> 3630 /// Standard HRESULT error code. 3631 /// </returns> 3632 HRESULT GetCurrentTransform( 3633 void* clientDrawingContext, 3634 /*out*/ DWRITE_MATRIX* transform 3635 ); 3636 3637 /// <summary> 3638 /// Gets the number of physical pixels per DIP. A DIP (device-independent pixel) is 1/96 inch, 3639 /// so the pixelsPerDip value is the number of logical pixels per inch divided by 96 (yielding 3640 /// a value of 1 for 96 DPI and 1.25 for 120). 3641 /// </summary> 3642 /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param> 3643 /// <param name="pixelsPerDip">Receives the number of physical pixels per DIP.</param> 3644 /// <returns> 3645 /// Standard HRESULT error code. 3646 /// </returns> 3647 HRESULT GetPixelsPerDip( 3648 void* clientDrawingContext, 3649 /*out*/ FLOAT* pixelsPerDip 3650 ); 3651 } 3652 3653 /// <summary> 3654 /// The IDWriteTextRenderer interface represents a set of application-defined 3655 /// callbacks that perform rendering of text, inline objects, and decorations 3656 /// such as underlines. 3657 /// </summary> 3658 mixin( uuid!(IDWriteTextRenderer, "ef8a8135-5cc6-45fe-8825-c5a0724eb819") ); 3659 interface IDWriteTextRenderer : IDWritePixelSnapping 3660 { 3661 extern(Windows): 3662 /// <summary> 3663 /// IDWriteTextLayout::Draw calls this function to instruct the client to 3664 /// render a run of glyphs. 3665 /// </summary> 3666 /// <param name="clientDrawingContext">The context passed to 3667 /// IDWriteTextLayout::Draw.</param> 3668 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 3669 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 3670 /// <param name="measuringMode">Specifies measuring mode for glyphs in the run. 3671 /// Renderer implementations may choose different rendering modes for given measuring modes, 3672 /// but best results are seen when the rendering mode matches the corresponding measuring mode: 3673 /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL 3674 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC 3675 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL 3676 /// </param> 3677 /// <param name="glyphRun">The glyph run to draw.</param> 3678 /// <param name="glyphRunDescription">Properties of the characters 3679 /// associated with this run.</param> 3680 /// <param name="clientDrawingEffect">The drawing effect set in 3681 /// IDWriteTextLayout::SetDrawingEffect.</param> 3682 /// <returns> 3683 /// Standard HRESULT error code. 3684 /// </returns> 3685 HRESULT DrawGlyphRun( 3686 void* clientDrawingContext, 3687 FLOAT baselineOriginX, 3688 FLOAT baselineOriginY, 3689 DWRITE_MEASURING_MODE measuringMode, 3690 const(DWRITE_GLYPH_RUN)* glyphRun, 3691 const(DWRITE_GLYPH_RUN_DESCRIPTION)* glyphRunDescription, 3692 IUnknown clientDrawingEffect 3693 ); 3694 3695 /// <summary> 3696 /// IDWriteTextLayout::Draw calls this function to instruct the client to draw 3697 /// an underline. 3698 /// </summary> 3699 /// <param name="clientDrawingContext">The context passed to 3700 /// IDWriteTextLayout::Draw.</param> 3701 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 3702 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 3703 /// <param name="underline">Underline logical information.</param> 3704 /// <param name="clientDrawingEffect">The drawing effect set in 3705 /// IDWriteTextLayout::SetDrawingEffect.</param> 3706 /// <returns> 3707 /// Standard HRESULT error code. 3708 /// </returns> 3709 /// <remarks> 3710 /// A single underline can be broken into multiple calls, depending on 3711 /// how the formatting changes attributes. If font sizes/styles change 3712 /// within an underline, the thickness and offset will be averaged 3713 /// weighted according to characters. 3714 /// To get the correct top coordinate of the underline rect, add underline::offset 3715 /// to the baseline's Y. Otherwise the underline will be immediately under the text. 3716 /// The x coordinate will always be passed as the left side, regardless 3717 /// of text directionality. This simplifies drawing and reduces the 3718 /// problem of round-off that could potentially cause gaps or a double 3719 /// stamped alpha blend. To avoid alpha overlap, round the end points 3720 /// to the nearest device pixel. 3721 /// </remarks> 3722 HRESULT DrawUnderline( 3723 void* clientDrawingContext, 3724 FLOAT baselineOriginX, 3725 FLOAT baselineOriginY, 3726 const(DWRITE_UNDERLINE)* underline, 3727 IUnknown clientDrawingEffect 3728 ); 3729 3730 /// <summary> 3731 /// IDWriteTextLayout::Draw calls this function to instruct the client to draw 3732 /// a strikethrough. 3733 /// </summary> 3734 /// <param name="clientDrawingContext">The context passed to 3735 /// IDWriteTextLayout::Draw.</param> 3736 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 3737 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 3738 /// <param name="strikethrough">Strikethrough logical information.</param> 3739 /// <param name="clientDrawingEffect">The drawing effect set in 3740 /// IDWriteTextLayout::SetDrawingEffect.</param> 3741 /// <returns> 3742 /// Standard HRESULT error code. 3743 /// </returns> 3744 /// <remarks> 3745 /// A single strikethrough can be broken into multiple calls, depending on 3746 /// how the formatting changes attributes. Strikethrough is not averaged 3747 /// across font sizes/styles changes. 3748 /// To get the correct top coordinate of the strikethrough rect, 3749 /// add strikethrough::offset to the baseline's Y. 3750 /// Like underlines, the x coordinate will always be passed as the left side, 3751 /// regardless of text directionality. 3752 /// </remarks> 3753 HRESULT DrawStrikethrough( 3754 void* clientDrawingContext, 3755 FLOAT baselineOriginX, 3756 FLOAT baselineOriginY, 3757 const(DWRITE_STRIKETHROUGH)* strikethrough, 3758 IUnknown clientDrawingEffect 3759 ); 3760 3761 /// <summary> 3762 /// IDWriteTextLayout::Draw calls this application callback when it needs to 3763 /// draw an inline object. 3764 /// </summary> 3765 /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param> 3766 /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param> 3767 /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param> 3768 /// <param name="inlineObject">The object set using IDWriteTextLayout::SetInlineObject.</param> 3769 /// <param name="isSideways">The object should be drawn on its side.</param> 3770 /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param> 3771 /// <param name="clientDrawingEffect">The drawing effect set in 3772 /// IDWriteTextLayout::SetDrawingEffect.</param> 3773 /// <returns> 3774 /// Standard HRESULT error code. 3775 /// </returns> 3776 /// <remarks> 3777 /// The right-to-left flag is a hint for those cases where it would look 3778 /// strange for the image to be shown normally (like an arrow pointing to 3779 /// right to indicate a submenu). 3780 /// </remarks> 3781 HRESULT DrawInlineObject( 3782 void* clientDrawingContext, 3783 FLOAT originX, 3784 FLOAT originY, 3785 IDWriteInlineObject inlineObject, 3786 BOOL isSideways, 3787 BOOL isRightToLeft, 3788 IUnknown clientDrawingEffect 3789 ); 3790 } 3791 3792 /// <summary> 3793 /// The IDWriteTextLayout interface represents a block of text after it has 3794 /// been fully analyzed and formatted. 3795 /// 3796 /// All coordinates are in device independent pixels (DIPs). 3797 /// </summary> 3798 mixin( uuid!(IDWriteTextLayout, "53737037-6d14-410b-9bfe-0b182bb70961") ); 3799 interface IDWriteTextLayout : IDWriteTextFormat 3800 { 3801 extern(Windows): 3802 /// <summary> 3803 /// Set layout maximum width 3804 /// </summary> 3805 /// <param name="maxWidth">Layout maximum width</param> 3806 /// <returns> 3807 /// Standard HRESULT error code. 3808 /// </returns> 3809 HRESULT SetMaxWidth( 3810 FLOAT maxWidth 3811 ); 3812 3813 /// <summary> 3814 /// Set layout maximum height 3815 /// </summary> 3816 /// <param name="maxHeight">Layout maximum height</param> 3817 /// <returns> 3818 /// Standard HRESULT error code. 3819 /// </returns> 3820 HRESULT SetMaxHeight( 3821 FLOAT maxHeight 3822 ); 3823 3824 /// <summary> 3825 /// Set the font collection. 3826 /// </summary> 3827 /// <param name="fontCollection">The font collection to set</param> 3828 /// <param name="textRange">Text range to which this change applies.</param> 3829 /// <returns> 3830 /// Standard HRESULT error code. 3831 /// </returns> 3832 HRESULT SetFontCollection( 3833 IDWriteFontCollection fontCollection, 3834 DWRITE_TEXT_RANGE textRange 3835 ); 3836 3837 /// <summary> 3838 /// Set null-terminated font family name. 3839 /// </summary> 3840 /// <param name="fontFamilyName">Font family name</param> 3841 /// <param name="textRange">Text range to which this change applies.</param> 3842 /// <returns> 3843 /// Standard HRESULT error code. 3844 /// </returns> 3845 HRESULT SetFontFamilyName( 3846 const(WCHAR)* fontFamilyName, 3847 DWRITE_TEXT_RANGE textRange 3848 ); 3849 3850 /// <summary> 3851 /// Set font weight. 3852 /// </summary> 3853 /// <param name="fontWeight">Font weight</param> 3854 /// <param name="textRange">Text range to which this change applies.</param> 3855 /// <returns> 3856 /// Standard HRESULT error code. 3857 /// </returns> 3858 HRESULT SetFontWeight( 3859 DWRITE_FONT_WEIGHT fontWeight, 3860 DWRITE_TEXT_RANGE textRange 3861 ); 3862 3863 /// <summary> 3864 /// Set font style. 3865 /// </summary> 3866 /// <param name="fontStyle">Font style</param> 3867 /// <param name="textRange">Text range to which this change applies.</param> 3868 /// <returns> 3869 /// Standard HRESULT error code. 3870 /// </returns> 3871 HRESULT SetFontStyle( 3872 DWRITE_FONT_STYLE fontStyle, 3873 DWRITE_TEXT_RANGE textRange 3874 ); 3875 3876 /// <summary> 3877 /// Set font stretch. 3878 /// </summary> 3879 /// <param name="fontStretch">font stretch</param> 3880 /// <param name="textRange">Text range to which this change applies.</param> 3881 /// <returns> 3882 /// Standard HRESULT error code. 3883 /// </returns> 3884 HRESULT SetFontStretch( 3885 DWRITE_FONT_STRETCH fontStretch, 3886 DWRITE_TEXT_RANGE textRange 3887 ); 3888 3889 /// <summary> 3890 /// Set font em height. 3891 /// </summary> 3892 /// <param name="fontSize">Font em height</param> 3893 /// <param name="textRange">Text range to which this change applies.</param> 3894 /// <returns> 3895 /// Standard HRESULT error code. 3896 /// </returns> 3897 HRESULT SetFontSize( 3898 FLOAT fontSize, 3899 DWRITE_TEXT_RANGE textRange 3900 ); 3901 3902 /// <summary> 3903 /// Set underline. 3904 /// </summary> 3905 /// <param name="hasUnderline">The Boolean flag indicates whether underline takes place</param> 3906 /// <param name="textRange">Text range to which this change applies.</param> 3907 /// <returns> 3908 /// Standard HRESULT error code. 3909 /// </returns> 3910 HRESULT SetUnderline( 3911 BOOL hasUnderline, 3912 DWRITE_TEXT_RANGE textRange 3913 ); 3914 3915 /// <summary> 3916 /// Set strikethrough. 3917 /// </summary> 3918 /// <param name="hasStrikethrough">The Boolean flag indicates whether strikethrough takes place</param> 3919 /// <param name="textRange">Text range to which this change applies.</param> 3920 /// <returns> 3921 /// Standard HRESULT error code. 3922 /// </returns> 3923 HRESULT SetStrikethrough( 3924 BOOL hasStrikethrough, 3925 DWRITE_TEXT_RANGE textRange 3926 ); 3927 3928 /// <summary> 3929 /// Set application-defined drawing effect. 3930 /// </summary> 3931 /// <param name="drawingEffect">Pointer to an application-defined drawing effect.</param> 3932 /// <param name="textRange">Text range to which this change applies.</param> 3933 /// <returns> 3934 /// Standard HRESULT error code. 3935 /// </returns> 3936 /// <remarks> 3937 /// This drawing effect is associated with the specified range and will be passed back 3938 /// to the application via the callback when the range is drawn at drawing time. 3939 /// </remarks> 3940 HRESULT SetDrawingEffect( 3941 IUnknown drawingEffect, 3942 DWRITE_TEXT_RANGE textRange 3943 ); 3944 3945 /// <summary> 3946 /// Set inline object. 3947 /// </summary> 3948 /// <param name="inlineObject">Pointer to an application-implemented inline object.</param> 3949 /// <param name="textRange">Text range to which this change applies.</param> 3950 /// <returns> 3951 /// Standard HRESULT error code. 3952 /// </returns> 3953 /// <remarks> 3954 /// This inline object applies to the specified range and will be passed back 3955 /// to the application via the DrawInlineObject callback when the range is drawn. 3956 /// Any text in that range will be suppressed. 3957 /// </remarks> 3958 HRESULT SetInlineObject( 3959 IDWriteInlineObject inlineObject, 3960 DWRITE_TEXT_RANGE textRange 3961 ); 3962 3963 /// <summary> 3964 /// Set font typography features. 3965 /// </summary> 3966 /// <param name="typography">Pointer to font typography setting.</param> 3967 /// <param name="textRange">Text range to which this change applies.</param> 3968 /// <returns> 3969 /// Standard HRESULT error code. 3970 /// </returns> 3971 HRESULT SetTypography( 3972 IDWriteTypography typography, 3973 DWRITE_TEXT_RANGE textRange 3974 ); 3975 3976 /// <summary> 3977 /// Set locale name. 3978 /// </summary> 3979 /// <param name="localeName">Locale name</param> 3980 /// <param name="textRange">Text range to which this change applies.</param> 3981 /// <returns> 3982 /// Standard HRESULT error code. 3983 /// </returns> 3984 HRESULT SetLocaleName( 3985 const(WCHAR)* localeName, 3986 DWRITE_TEXT_RANGE textRange 3987 ); 3988 3989 /// <summary> 3990 /// Get layout maximum width 3991 /// </summary> 3992 FLOAT GetMaxWidth(); 3993 3994 /// <summary> 3995 /// Get layout maximum height 3996 /// </summary> 3997 FLOAT GetMaxHeight(); 3998 3999 /// <summary> 4000 /// Get the font collection where the current position is at. 4001 /// </summary> 4002 /// <param name="currentPosition">The current text position.</param> 4003 /// <param name="fontCollection">The current font collection</param> 4004 /// <param name="textRange">Text range to which this change applies.</param> 4005 /// <returns> 4006 /// Standard HRESULT error code. 4007 /// </returns> 4008 HRESULT GetFontCollection( 4009 UINT32 currentPosition, 4010 /*out*/ IDWriteFontCollection* fontCollection, 4011 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4012 ); 4013 4014 /// <summary> 4015 /// Get the length of the font family name where the current position is at. 4016 /// </summary> 4017 /// <param name="currentPosition">The current text position.</param> 4018 /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param> 4019 /// <param name="textRange">The position range of the current format.</param> 4020 /// <returns> 4021 /// Standard HRESULT error code. 4022 /// </returns> 4023 HRESULT GetFontFamilyNameLength( 4024 UINT32 currentPosition, 4025 /*out*/ UINT32* nameLength, 4026 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4027 ); 4028 4029 /// <summary> 4030 /// Copy the font family name where the current position is at. 4031 /// </summary> 4032 /// <param name="currentPosition">The current text position.</param> 4033 /// <param name="fontFamilyName">Character array that receives the current font family name</param> 4034 /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> 4035 /// <param name="textRange">The position range of the current format.</param> 4036 /// <returns> 4037 /// Standard HRESULT error code. 4038 /// </returns> 4039 HRESULT GetFontFamilyName( 4040 UINT32 currentPosition, 4041 /*out*/ WCHAR* fontFamilyName, 4042 UINT32 nameSize, 4043 DWRITE_TEXT_RANGE* textRange = null 4044 ); 4045 4046 /// <summary> 4047 /// Get the font weight where the current position is at. 4048 /// </summary> 4049 /// <param name="currentPosition">The current text position.</param> 4050 /// <param name="fontWeight">The current font weight</param> 4051 /// <param name="textRange">The position range of the current format.</param> 4052 /// <returns> 4053 /// Standard HRESULT error code. 4054 /// </returns> 4055 HRESULT GetFontWeight( 4056 UINT32 currentPosition, 4057 /*out*/ DWRITE_FONT_WEIGHT* fontWeight, 4058 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4059 ); 4060 4061 /// <summary> 4062 /// Get the font style where the current position is at. 4063 /// </summary> 4064 /// <param name="currentPosition">The current text position.</param> 4065 /// <param name="fontStyle">The current font style</param> 4066 /// <param name="textRange">The position range of the current format.</param> 4067 /// <returns> 4068 /// Standard HRESULT error code. 4069 /// </returns> 4070 HRESULT GetFontStyle( 4071 UINT32 currentPosition, 4072 /*out*/ DWRITE_FONT_STYLE* fontStyle, 4073 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4074 ); 4075 4076 /// <summary> 4077 /// Get the font stretch where the current position is at. 4078 /// </summary> 4079 /// <param name="currentPosition">The current text position.</param> 4080 /// <param name="fontStretch">The current font stretch</param> 4081 /// <param name="textRange">The position range of the current format.</param> 4082 /// <returns> 4083 /// Standard HRESULT error code. 4084 /// </returns> 4085 HRESULT GetFontStretch( 4086 UINT32 currentPosition, 4087 /*out*/ DWRITE_FONT_STRETCH* fontStretch, 4088 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4089 ); 4090 4091 /// <summary> 4092 /// Get the font em height where the current position is at. 4093 /// </summary> 4094 /// <param name="currentPosition">The current text position.</param> 4095 /// <param name="fontSize">The current font em height</param> 4096 /// <param name="textRange">The position range of the current format.</param> 4097 /// <returns> 4098 /// Standard HRESULT error code. 4099 /// </returns> 4100 HRESULT GetFontSize( 4101 UINT32 currentPosition, 4102 /*out*/ FLOAT* fontSize, 4103 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4104 ); 4105 4106 /// <summary> 4107 /// Get the underline presence where the current position is at. 4108 /// </summary> 4109 /// <param name="currentPosition">The current text position.</param> 4110 /// <param name="hasUnderline">The Boolean flag indicates whether text is underlined.</param> 4111 /// <param name="textRange">The position range of the current format.</param> 4112 /// <returns> 4113 /// Standard HRESULT error code. 4114 /// </returns> 4115 HRESULT GetUnderline( 4116 UINT32 currentPosition, 4117 /*out*/ BOOL* hasUnderline, 4118 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4119 ); 4120 4121 /// <summary> 4122 /// Get the strikethrough presence where the current position is at. 4123 /// </summary> 4124 /// <param name="currentPosition">The current text position.</param> 4125 /// <param name="hasStrikethrough">The Boolean flag indicates whether text has strikethrough.</param> 4126 /// <param name="textRange">The position range of the current format.</param> 4127 /// <returns> 4128 /// Standard HRESULT error code. 4129 /// </returns> 4130 HRESULT GetStrikethrough( 4131 UINT32 currentPosition, 4132 /*out*/ BOOL* hasStrikethrough, 4133 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4134 ); 4135 4136 /// <summary> 4137 /// Get the application-defined drawing effect where the current position is at. 4138 /// </summary> 4139 /// <param name="currentPosition">The current text position.</param> 4140 /// <param name="drawingEffect">The current application-defined drawing effect.</param> 4141 /// <param name="textRange">The position range of the current format.</param> 4142 /// <returns> 4143 /// Standard HRESULT error code. 4144 /// </returns> 4145 HRESULT GetDrawingEffect( 4146 UINT32 currentPosition, 4147 /*out*/ IUnknown* drawingEffect, 4148 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4149 ); 4150 4151 /// <summary> 4152 /// Get the inline object at the given position. 4153 /// </summary> 4154 /// <param name="currentPosition">The given text position.</param> 4155 /// <param name="inlineObject">The inline object.</param> 4156 /// <param name="textRange">The position range of the current format.</param> 4157 /// <returns> 4158 /// Standard HRESULT error code. 4159 /// </returns> 4160 HRESULT GetInlineObject( 4161 UINT32 currentPosition, 4162 /*out*/ IDWriteInlineObject* inlineObject, 4163 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4164 ); 4165 4166 /// <summary> 4167 /// Get the typography setting where the current position is at. 4168 /// </summary> 4169 /// <param name="currentPosition">The current text position.</param> 4170 /// <param name="typography">The current typography setting.</param> 4171 /// <param name="textRange">The position range of the current format.</param> 4172 /// <returns> 4173 /// Standard HRESULT error code. 4174 /// </returns> 4175 HRESULT GetTypography( 4176 UINT32 currentPosition, 4177 /*out*/ IDWriteTypography* typography, 4178 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4179 ); 4180 4181 /// <summary> 4182 /// Get the length of the locale name where the current position is at. 4183 /// </summary> 4184 /// <param name="currentPosition">The current text position.</param> 4185 /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param> 4186 /// <param name="textRange">The position range of the current format.</param> 4187 /// <returns> 4188 /// Standard HRESULT error code. 4189 /// </returns> 4190 HRESULT GetLocaleNameLength( 4191 UINT32 currentPosition, 4192 /*out*/ UINT32* nameLength, 4193 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4194 ); 4195 4196 /// <summary> 4197 /// Get the locale name where the current position is at. 4198 /// </summary> 4199 /// <param name="currentPosition">The current text position.</param> 4200 /// <param name="localeName">Character array that receives the current locale name</param> 4201 /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> 4202 /// <param name="textRange">The position range of the current format.</param> 4203 /// <returns> 4204 /// Standard HRESULT error code. 4205 /// </returns> 4206 HRESULT GetLocaleName( 4207 UINT32 currentPosition, 4208 /*out*/ WCHAR* localeName, 4209 UINT32 nameSize, 4210 /*out*/ DWRITE_TEXT_RANGE* textRange = null 4211 ); 4212 4213 /// <summary> 4214 /// Initiate drawing of the text. 4215 /// </summary> 4216 /// <param name="clientDrawingContext">An application defined value 4217 /// included in rendering callbacks.</param> 4218 /// <param name="renderer">The set of application-defined callbacks that do 4219 /// the actual rendering.</param> 4220 /// <param name="originX">X-coordinate of the layout's left side.</param> 4221 /// <param name="originY">Y-coordinate of the layout's top side.</param> 4222 /// <returns> 4223 /// Standard HRESULT error code. 4224 /// </returns> 4225 HRESULT Draw( 4226 void* clientDrawingContext, 4227 IDWriteTextRenderer renderer, 4228 FLOAT originX, 4229 FLOAT originY 4230 ); 4231 4232 /// <summary> 4233 /// GetLineMetrics returns properties of each line. 4234 /// </summary> 4235 /// <param name="lineMetrics">The array to fill with line information.</param> 4236 /// <param name="maxLineCount">The maximum size of the lineMetrics array.</param> 4237 /// <param name="actualLineCount">The actual size of the lineMetrics 4238 /// array that is needed.</param> 4239 /// <returns> 4240 /// Standard HRESULT error code. 4241 /// </returns> 4242 /// <remarks> 4243 /// If maxLineCount is not large enough E_NOT_SUFFICIENT_BUFFER, 4244 /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), 4245 /// is returned and *actualLineCount is set to the number of lines 4246 /// needed. 4247 /// </remarks> 4248 HRESULT GetLineMetrics( 4249 /*out*/ DWRITE_LINE_METRICS* lineMetrics, 4250 UINT32 maxLineCount, 4251 /*out*/ UINT32* actualLineCount 4252 ); 4253 4254 /// <summary> 4255 /// GetMetrics retrieves overall metrics for the formatted string. 4256 /// </summary> 4257 /// <param name="textMetrics">The returned metrics.</param> 4258 /// <returns> 4259 /// Standard HRESULT error code. 4260 /// </returns> 4261 /// <remarks> 4262 /// Drawing effects like underline and strikethrough do not contribute 4263 /// to the text size, which is essentially the sum of advance widths and 4264 /// line heights. Additionally, visible swashes and other graphic 4265 /// adornments may extend outside the returned width and height. 4266 /// </remarks> 4267 HRESULT GetMetrics( 4268 /*out*/ DWRITE_TEXT_METRICS* textMetrics 4269 ); 4270 4271 /// <summary> 4272 /// GetOverhangMetrics returns the overhangs (in DIPs) of the layout and all 4273 /// objects contained in it, including text glyphs and inline objects. 4274 /// </summary> 4275 /// <param name="overhangs">Overshoots of visible extents (in DIPs) outside the layout.</param> 4276 /// <returns> 4277 /// Standard HRESULT error code. 4278 /// </returns> 4279 /// <remarks> 4280 /// Any underline and strikethrough do not contribute to the black box 4281 /// determination, since these are actually drawn by the renderer, which 4282 /// is allowed to draw them in any variety of styles. 4283 /// </remarks> 4284 HRESULT GetOverhangMetrics( 4285 /*out*/ DWRITE_OVERHANG_METRICS* overhangs 4286 ); 4287 4288 /// <summary> 4289 /// Retrieve logical properties and measurement of each cluster. 4290 /// </summary> 4291 /// <param name="clusterMetrics">The array to fill with cluster information.</param> 4292 /// <param name="maxClusterCount">The maximum size of the clusterMetrics array.</param> 4293 /// <param name="actualClusterCount">The actual size of the clusterMetrics array that is needed.</param> 4294 /// <returns> 4295 /// Standard HRESULT error code. 4296 /// </returns> 4297 /// <remarks> 4298 /// If maxClusterCount is not large enough E_NOT_SUFFICIENT_BUFFER, 4299 /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), 4300 /// is returned and *actualClusterCount is set to the number of clusters 4301 /// needed. 4302 /// </remarks> 4303 HRESULT GetClusterMetrics( 4304 /*out*/ DWRITE_CLUSTER_METRICS* clusterMetrics, 4305 UINT32 maxClusterCount, 4306 /*out*/ UINT32* actualClusterCount 4307 ); 4308 4309 /// <summary> 4310 /// Determines the minimum possible width the layout can be set to without 4311 /// emergency breaking between the characters of whole words. 4312 /// </summary> 4313 /// <param name="minWidth">Minimum width.</param> 4314 /// <returns> 4315 /// Standard HRESULT error code. 4316 /// </returns> 4317 HRESULT DetermineMinWidth( 4318 /*out*/ FLOAT* minWidth 4319 ); 4320 4321 /// <summary> 4322 /// Given a coordinate (in DIPs) relative to the top-left of the layout box, 4323 /// this returns the corresponding hit-test metrics of the text string where 4324 /// the hit-test has occurred. This is useful for mapping mouse clicks to caret 4325 /// positions. When the given coordinate is outside the text string, the function 4326 /// sets the output value *isInside to false but returns the nearest character 4327 /// position. 4328 /// </summary> 4329 /// <param name="pointX">X coordinate to hit-test, relative to the top-left location of the layout box.</param> 4330 /// <param name="pointY">Y coordinate to hit-test, relative to the top-left location of the layout box.</param> 4331 /// <param name="isTrailingHit">Output flag indicating whether the hit-test location is at the leading or the trailing 4332 /// side of the character. When the output *isInside value is set to false, this value is set according to the output 4333 /// *position value to represent the edge closest to the hit-test location. </param> 4334 /// <param name="isInside">Output flag indicating whether the hit-test location is inside the text string. 4335 /// When false, the position nearest the text's edge is returned.</param> 4336 /// <param name="hitTestMetrics">Output geometry fully enclosing the hit-test location. When the output *isInside value 4337 /// is set to false, this structure represents the geometry enclosing the edge closest to the hit-test location.</param> 4338 /// <returns> 4339 /// Standard HRESULT error code. 4340 /// </returns> 4341 HRESULT HitTestPoint( 4342 FLOAT pointX, 4343 FLOAT pointY, 4344 /*out*/ BOOL* isTrailingHit, 4345 /*out*/ BOOL* isInside, 4346 /*out*/ DWRITE_HIT_TEST_METRICS* hitTestMetrics 4347 ); 4348 4349 /// <summary> 4350 /// Given a text position and whether the caret is on the leading or trailing 4351 /// edge of that position, this returns the corresponding coordinate (in DIPs) 4352 /// relative to the top-left of the layout box. This is most useful for drawing 4353 /// the caret's current position, but it could also be used to anchor an IME to the 4354 /// typed text or attach a floating menu near the point of interest. It may also be 4355 /// used to programmatically obtain the geometry of a particular text position 4356 /// for UI automation. 4357 /// </summary> 4358 /// <param name="textPosition">Text position to get the coordinate of.</param> 4359 /// <param name="isTrailingHit">Flag indicating whether the location is of the leading or the trailing side of the specified text position. </param> 4360 /// <param name="pointX">Output caret X, relative to the top-left of the layout box.</param> 4361 /// <param name="pointY">Output caret Y, relative to the top-left of the layout box.</param> 4362 /// <param name="hitTestMetrics">Output geometry fully enclosing the specified text position.</param> 4363 /// <returns> 4364 /// Standard HRESULT error code. 4365 /// </returns> 4366 /// <remarks> 4367 /// When drawing a caret at the returned X,Y, it should be centered on X 4368 /// and drawn from the Y coordinate down. The height will be the size of the 4369 /// hit-tested text (which can vary in size within a line). 4370 /// Reading direction also affects which side of the character the caret is drawn. 4371 /// However, the returned X coordinate will be correct for either case. 4372 /// You can get a text length back that is larger than a single character. 4373 /// This happens for complex scripts when multiple characters form a single cluster, 4374 /// when diacritics join their base character, or when you test a surrogate pair. 4375 /// </remarks> 4376 HRESULT HitTestTextPosition( 4377 UINT32 textPosition, 4378 BOOL isTrailingHit, 4379 /*out*/ FLOAT* pointX, 4380 /*out*/ FLOAT* pointY, 4381 /*out*/ DWRITE_HIT_TEST_METRICS* hitTestMetrics 4382 ); 4383 4384 /// <summary> 4385 /// The application calls this function to get a set of hit-test metrics 4386 /// corresponding to a range of text positions. The main usage for this 4387 /// is to draw highlighted selection of the text string. 4388 /// 4389 /// The function returns E_NOT_SUFFICIENT_BUFFER, which is equivalent to 4390 /// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), when the buffer size of 4391 /// hitTestMetrics is too small to hold all the regions calculated by the 4392 /// function. In such situation, the function sets the output value 4393 /// *actualHitTestMetricsCount to the number of geometries calculated. 4394 /// The application is responsible to allocate a new buffer of greater 4395 /// size and call the function again. 4396 /// 4397 /// A good value to use as an initial value for maxHitTestMetricsCount may 4398 /// be calculated from the following equation: 4399 /// maxHitTestMetricsCount = lineCount * maxBidiReorderingDepth 4400 /// 4401 /// where lineCount is obtained from the value of the output argument 4402 /// *actualLineCount from the function IDWriteTextLayout::GetLineMetrics, 4403 /// and the maxBidiReorderingDepth value from the DWRITE_TEXT_METRICS 4404 /// structure of the output argument *textMetrics from the function 4405 /// IDWriteFactory::CreateTextLayout. 4406 /// </summary> 4407 /// <param name="textPosition">First text position of the specified range.</param> 4408 /// <param name="textLength">Number of positions of the specified range.</param> 4409 /// <param name="originX">Offset of the X origin (left of the layout box) which is added to each of the hit-test metrics returned.</param> 4410 /// <param name="originY">Offset of the Y origin (top of the layout box) which is added to each of the hit-test metrics returned.</param> 4411 /// <param name="hitTestMetrics">Pointer to a buffer of the output geometry fully enclosing the specified position range.</param> 4412 /// <param name="maxHitTestMetricsCount">Maximum number of distinct metrics it could hold in its buffer memory.</param> 4413 /// <param name="actualHitTestMetricsCount">Actual number of metrics returned or needed.</param> 4414 /// <returns> 4415 /// Standard HRESULT error code. 4416 /// </returns> 4417 /// <remarks> 4418 /// There are no gaps in the returned metrics. While there could be visual gaps, 4419 /// depending on bidi ordering, each range is contiguous and reports all the text, 4420 /// including any hidden characters and trimmed text. 4421 /// The height of each returned range will be the same within each line, regardless 4422 /// of how the font sizes vary. 4423 /// </remarks> 4424 HRESULT HitTestTextRange( 4425 UINT32 textPosition, 4426 UINT32 textLength, 4427 FLOAT originX, 4428 FLOAT originY, 4429 /*out*/ DWRITE_HIT_TEST_METRICS* hitTestMetrics, 4430 UINT32 maxHitTestMetricsCount, 4431 /*out*/ UINT32* actualHitTestMetricsCount 4432 ); 4433 } 4434 4435 4436 /// <summary> 4437 /// Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs. 4438 /// </summary> 4439 mixin( uuid!(IDWriteBitmapRenderTarget, "5e5a32a3-8dff-4773-9ff6-0696eab77267") ); 4440 interface IDWriteBitmapRenderTarget : IUnknown 4441 { 4442 extern(Windows): 4443 /// <summary> 4444 /// Draws a run of glyphs to the bitmap. 4445 /// </summary> 4446 /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param> 4447 /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param> 4448 /// <param name="measuringMode">Specifies measuring mode for glyphs in the run. 4449 /// Renderer implementations may choose different rendering modes for different measuring modes, for example 4450 /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL, 4451 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC, and 4452 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL. 4453 /// </param> 4454 /// <param name="glyphRun">Structure containing the properties of the glyph run.</param> 4455 /// <param name="renderingParams">Object that controls rendering behavior.</param> 4456 /// <param name="textColor">Specifies the foreground color of the text.</param> 4457 /// <param name="blackBoxRect">Optional rectangle that receives the bounding box (in pixels not DIPs) of all the pixels affected by 4458 /// drawing the glyph run. The black box rectangle may extend beyond the dimensions of the bitmap.</param> 4459 /// <returns> 4460 /// Standard HRESULT error code. 4461 /// </returns> 4462 HRESULT DrawGlyphRun( 4463 FLOAT baselineOriginX, 4464 FLOAT baselineOriginY, 4465 DWRITE_MEASURING_MODE measuringMode, 4466 const(DWRITE_GLYPH_RUN)* glyphRun, 4467 IDWriteRenderingParams renderingParams, 4468 COLORREF textColor, 4469 RECT* blackBoxRect = null 4470 ); 4471 4472 /// <summary> 4473 /// Gets a handle to the memory device context. 4474 /// </summary> 4475 /// <returns> 4476 /// Returns the device context handle. 4477 /// </returns> 4478 /// <remarks> 4479 /// An application can use the device context to draw using GDI functions. An application can obtain the bitmap handle 4480 /// (HBITMAP) by calling GetCurrentObject. An application that wants information about the underlying bitmap, including 4481 /// a pointer to the pixel data, can call GetObject to fill in a DIBSECTION structure. The bitmap is always a 32-bit 4482 /// top-down DIB. 4483 /// </remarks> 4484 HDC GetMemoryDC(); 4485 4486 /// <summary> 4487 /// Gets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number 4488 /// if pixels per inch divided by 96. 4489 /// </summary> 4490 /// <returns> 4491 /// Returns the number of bitmap pixels per DIP. 4492 /// </returns> 4493 FLOAT GetPixelsPerDip(); 4494 4495 /// <summary> 4496 /// Sets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number 4497 /// if pixels per inch divided by 96. 4498 /// </summary> 4499 /// <param name="pixelsPerDip">Specifies the number of pixels per DIP.</param> 4500 /// <returns> 4501 /// Standard HRESULT error code. 4502 /// </returns> 4503 HRESULT SetPixelsPerDip( 4504 FLOAT pixelsPerDip 4505 ); 4506 4507 /// <summary> 4508 /// Gets the transform that maps abstract coordinate to DIPs. By default this is the identity 4509 /// transform. Note that this is unrelated to the world transform of the underlying device 4510 /// context. 4511 /// </summary> 4512 /// <param name="transform">Receives the transform.</param> 4513 /// <returns> 4514 /// Standard HRESULT error code. 4515 /// </returns> 4516 HRESULT GetCurrentTransform( 4517 /*out*/ DWRITE_MATRIX* transform 4518 ); 4519 4520 /// <summary> 4521 /// Sets the transform that maps abstract coordinate to DIPs. This does not affect the world 4522 /// transform of the underlying device context. 4523 /// </summary> 4524 /// <param name="transform">Specifies the new transform. This parameter can be NULL, in which 4525 /// case the identity transform is implied.</param> 4526 /// <returns> 4527 /// Standard HRESULT error code. 4528 /// </returns> 4529 HRESULT SetCurrentTransform( 4530 const(DWRITE_MATRIX)* transform 4531 ); 4532 4533 /// <summary> 4534 /// Gets the dimensions of the bitmap. 4535 /// </summary> 4536 /// <param name="size">Receives the size of the bitmap in pixels.</param> 4537 /// <returns> 4538 /// Standard HRESULT error code. 4539 /// </returns> 4540 HRESULT GetSize( 4541 /*out*/ SIZE* size 4542 ); 4543 4544 /// <summary> 4545 /// Resizes the bitmap. 4546 /// </summary> 4547 /// <param name="width">New bitmap width, in pixels.</param> 4548 /// <param name="height">New bitmap height, in pixels.</param> 4549 /// <returns> 4550 /// Standard HRESULT error code. 4551 /// </returns> 4552 HRESULT Resize( 4553 UINT32 width, 4554 UINT32 height 4555 ); 4556 } 4557 4558 /// <summary> 4559 /// The GDI interop interface provides interoperability with GDI. 4560 /// </summary> 4561 mixin( uuid!(IDWriteGdiInterop, "1edd9491-9853-4299-898f-6432983b6f3a") ); 4562 interface IDWriteGdiInterop : IUnknown 4563 { 4564 extern(Windows): 4565 /// <summary> 4566 /// Creates a font object that matches the properties specified by the LOGFONT structure. 4567 /// </summary> 4568 /// <param name="logFont">Structure containing a GDI-compatible font description.</param> 4569 /// <param name="font">Receives a newly created font object if successful, or NULL in case of error.</param> 4570 /// <returns> 4571 /// Standard HRESULT error code. 4572 /// </returns> 4573 HRESULT CreateFontFromLOGFONT( 4574 const(LOGFONTW)* logFont, 4575 /*out*/ IDWriteFont* font 4576 ); 4577 4578 /// <summary> 4579 /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font. 4580 /// </summary> 4581 /// <param name="font">Specifies a font in the system font collection.</param> 4582 /// <param name="logFont">Structure that receives a GDI-compatible font description.</param> 4583 /// <param name="isSystemFont">Contains TRUE if the specified font object is part of the system font collection 4584 /// or FALSE otherwise.</param> 4585 /// <returns> 4586 /// Standard HRESULT error code. 4587 /// </returns> 4588 HRESULT ConvertFontToLOGFONT( 4589 IDWriteFont font, 4590 /*out*/ LOGFONTW* logFont, 4591 /*out*/ BOOL* isSystemFont 4592 ); 4593 4594 /// <summary> 4595 /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font. 4596 /// </summary> 4597 /// <param name="font">Specifies a font face.</param> 4598 /// <param name="logFont">Structure that receives a GDI-compatible font description.</param> 4599 /// <returns> 4600 /// Standard HRESULT error code. 4601 /// </returns> 4602 HRESULT ConvertFontFaceToLOGFONT( 4603 IDWriteFontFace font, 4604 /*out*/ LOGFONTW* logFont 4605 ); 4606 4607 /// <summary> 4608 /// Creates a font face object that corresponds to the currently selected HFONT. 4609 /// </summary> 4610 /// <param name="hdc">Handle to a device context into which a font has been selected. It is assumed that the client 4611 /// has already performed font mapping and that the font selected into the DC is the actual font that would be used 4612 /// for rendering glyphs.</param> 4613 /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param> 4614 /// <returns> 4615 /// Standard HRESULT error code. 4616 /// </returns> 4617 HRESULT CreateFontFaceFromHdc( 4618 HDC hdc, 4619 /*out*/ IDWriteFontFace* fontFace 4620 ); 4621 4622 /// <summary> 4623 /// Creates an object that encapsulates a bitmap and memory DC which can be used for rendering glyphs. 4624 /// </summary> 4625 /// <param name="hdc">Optional device context used to create a compatible memory DC.</param> 4626 /// <param name="width">Width of the bitmap.</param> 4627 /// <param name="height">Height of the bitmap.</param> 4628 /// <param name="renderTarget">Receives a pointer to the newly created render target.</param> 4629 HRESULT CreateBitmapRenderTarget( 4630 HDC hdc, 4631 UINT32 width, 4632 UINT32 height, 4633 /*out*/ IDWriteBitmapRenderTarget* renderTarget 4634 ); 4635 } 4636 4637 /// <summary> 4638 /// The DWRITE_TEXTURE_TYPE enumeration identifies a type of alpha texture. An alpha texture is a bitmap of alpha values, each 4639 /// representing the darkness (i.e., opacity) of a pixel or subpixel. 4640 /// </summary> 4641 alias DWRITE_TEXTURE_TYPE = int; 4642 enum : DWRITE_TEXTURE_TYPE 4643 { 4644 /// <summary> 4645 /// Specifies an alpha texture for aliased text rendering (i.e., bi-level, where each pixel is either fully opaque or fully transparent), 4646 /// with one byte per pixel. 4647 /// </summary> 4648 DWRITE_TEXTURE_ALIASED_1x1, 4649 4650 /// <summary> 4651 /// Specifies an alpha texture for ClearType text rendering, with three bytes per pixel in the horizontal dimension and 4652 /// one byte per pixel in the vertical dimension. 4653 /// </summary> 4654 DWRITE_TEXTURE_CLEARTYPE_3x1 4655 } 4656 4657 /// <summary> 4658 /// Maximum alpha value in a texture returned by IDWriteGlyphRunAnalysis::CreateAlphaTexture. 4659 /// </summary> 4660 enum DWRITE_ALPHA_MAX = 255; 4661 4662 /// <summary> 4663 /// Interface that encapsulates information used to render a glyph run. 4664 /// </summary> 4665 mixin( uuid!(IDWriteGlyphRunAnalysis, "7d97dbf7-e085-42d4-81e3-6a883bded118") ); 4666 interface IDWriteGlyphRunAnalysis : IUnknown 4667 { 4668 extern(Windows): 4669 /// <summary> 4670 /// Gets the bounding rectangle of the physical pixels affected by the glyph run. 4671 /// </summary> 4672 /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the 4673 /// bounding rectangle includes only bi-level glyphs. Otherwise, the bounding rectangle includes only anti-aliased 4674 /// glyphs.</param> 4675 /// <param name="textureBounds">Receives the bounding rectangle, or an empty rectangle if there are no glyphs 4676 /// if the specified type.</param> 4677 /// <returns> 4678 /// Standard HRESULT error code. 4679 /// </returns> 4680 HRESULT GetAlphaTextureBounds( 4681 DWRITE_TEXTURE_TYPE textureType, 4682 /*out*/ RECT* textureBounds 4683 ); 4684 4685 /// <summary> 4686 /// Creates an alpha texture of the specified type. 4687 /// </summary> 4688 /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the 4689 /// texture contains only bi-level glyphs. Otherwise, the texture contains only anti-aliased glyphs.</param> 4690 /// <param name="textureBounds">Specifies the bounding rectangle of the texture, which can be different than 4691 /// the bounding rectangle returned by GetAlphaTextureBounds.</param> 4692 /// <param name="alphaValues">Receives the array of alpha values.</param> 4693 /// <param name="bufferSize">Size of the alphaValues array. The minimum size depends on the dimensions of the 4694 /// rectangle and the type of texture requested.</param> 4695 /// <returns> 4696 /// Standard HRESULT error code. 4697 /// </returns> 4698 HRESULT CreateAlphaTexture( 4699 DWRITE_TEXTURE_TYPE textureType, 4700 const(RECT)* textureBounds, 4701 /*out*/ BYTE* alphaValues, 4702 UINT32 bufferSize 4703 ); 4704 4705 /// <summary> 4706 /// Gets properties required for ClearType blending. 4707 /// </summary> 4708 /// <param name="renderingParams">Rendering parameters object. In most cases, the values returned in the output 4709 /// parameters are based on the properties of this object. The exception is if a GDI-compatible rendering mode 4710 /// is specified.</param> 4711 /// <param name="blendGamma">Receives the gamma value to use for gamma correction.</param> 4712 /// <param name="blendEnhancedContrast">Receives the enhanced contrast value.</param> 4713 /// <param name="blendClearTypeLevel">Receives the ClearType level.</param> 4714 HRESULT GetAlphaBlendParams( 4715 IDWriteRenderingParams renderingParams, 4716 /*out*/ FLOAT* blendGamma, 4717 /*out*/ FLOAT* blendEnhancedContrast, 4718 /*out*/ FLOAT* blendClearTypeLevel 4719 ); 4720 } 4721 4722 /// <summary> 4723 /// The root factory interface for all DWrite objects. 4724 /// </summary> 4725 mixin( uuid!(IDWriteFactory, "b859ee5a-d838-4b5b-a2e8-1adc7d93db48") ); 4726 interface IDWriteFactory : IUnknown 4727 { 4728 extern(Windows): 4729 /// <summary> 4730 /// Gets a font collection representing the set of installed fonts. 4731 /// </summary> 4732 /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param> 4733 /// <param name="checkForUpdates">If this parameter is nonzero, the function performs an immediate check for changes to the set of 4734 /// installed fonts. If this parameter is FALSE, the function will still detect changes if the font cache service is running, but 4735 /// there may be some latency. For example, an application might specify TRUE if it has itself just installed a font and wants to 4736 /// be sure the font collection contains that font.</param> 4737 /// <returns> 4738 /// Standard HRESULT error code. 4739 /// </returns> 4740 HRESULT GetSystemFontCollection( 4741 /*out*/ IDWriteFontCollection* fontCollection, 4742 BOOL checkForUpdates = FALSE 4743 ); 4744 4745 /// <summary> 4746 /// Creates a font collection using a custom font collection loader. 4747 /// </summary> 4748 /// <param name="collectionLoader">Application-defined font collection loader, which must have been previously 4749 /// registered using RegisterFontCollectionLoader.</param> 4750 /// <param name="collectionKey">Key used by the loader to identify a collection of font files.</param> 4751 /// <param name="collectionKeySize">Size in bytes of the collection key.</param> 4752 /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param> 4753 /// <returns> 4754 /// Standard HRESULT error code. 4755 /// </returns> 4756 HRESULT CreateCustomFontCollection( 4757 IDWriteFontCollectionLoader collectionLoader, 4758 const(void*) collectionKey, 4759 UINT32 collectionKeySize, 4760 /*out*/ IDWriteFontCollection* fontCollection 4761 ); 4762 4763 /// <summary> 4764 /// Registers a custom font collection loader with the factory object. 4765 /// </summary> 4766 /// <param name="fontCollectionLoader">Application-defined font collection loader.</param> 4767 /// <returns> 4768 /// Standard HRESULT error code. 4769 /// </returns> 4770 HRESULT RegisterFontCollectionLoader( 4771 IDWriteFontCollectionLoader fontCollectionLoader 4772 ); 4773 4774 /// <summary> 4775 /// Unregisters a custom font collection loader that was previously registered using RegisterFontCollectionLoader. 4776 /// </summary> 4777 /// <param name="fontCollectionLoader">Application-defined font collection loader.</param> 4778 /// <returns> 4779 /// Standard HRESULT error code. 4780 /// </returns> 4781 HRESULT UnregisterFontCollectionLoader( 4782 IDWriteFontCollectionLoader fontCollectionLoader 4783 ); 4784 4785 /// <summary> 4786 /// CreateFontFileReference creates a font file reference object from a local font file. 4787 /// </summary> 4788 /// <param name="filePath">Absolute file path. Subsequent operations on the constructed object may fail 4789 /// if the user provided filePath doesn't correspond to a valid file on the disk.</param> 4790 /// <param name="lastWriteTime">Last modified time of the input file path. If the parameter is omitted, 4791 /// the function will access the font file to obtain its last write time, so the clients are encouraged to specify this value 4792 /// to avoid extra disk access. Subsequent operations on the constructed object may fail 4793 /// if the user provided lastWriteTime doesn't match the file on the disk.</param> 4794 /// <param name="fontFile">Contains newly created font file reference object, or NULL in case of failure.</param> 4795 /// <returns> 4796 /// Standard HRESULT error code. 4797 /// </returns> 4798 HRESULT CreateFontFileReference( 4799 const(WCHAR)* filePath, 4800 const(FILETIME)* lastWriteTime, 4801 /*out*/ IDWriteFontFile* fontFile 4802 ); 4803 4804 /// <summary> 4805 /// CreateCustomFontFileReference creates a reference to an application specific font file resource. 4806 /// This function enables an application or a document to use a font without having to install it on the system. 4807 /// The fontFileReferenceKey has to be unique only in the scope of the fontFileLoader used in this call. 4808 /// </summary> 4809 /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource 4810 /// during the lifetime of fontFileLoader.</param> 4811 /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param> 4812 /// <param name="fontFileLoader">Font file loader that will be used by the font system to load data from the file identified by 4813 /// fontFileReferenceKey.</param> 4814 /// <param name="fontFile">Contains the newly created font file object, or NULL in case of failure.</param> 4815 /// <returns> 4816 /// Standard HRESULT error code. 4817 /// </returns> 4818 /// <remarks> 4819 /// This function is provided for cases when an application or a document needs to use a font 4820 /// without having to install it on the system. fontFileReferenceKey has to be unique only in the scope 4821 /// of the fontFileLoader used in this call. 4822 /// </remarks> 4823 HRESULT CreateCustomFontFileReference( 4824 const(void*) fontFileReferenceKey, 4825 UINT32 fontFileReferenceKeySize, 4826 IDWriteFontFileLoader fontFileLoader, 4827 /*out*/ IDWriteFontFile* fontFile 4828 ); 4829 4830 /// <summary> 4831 /// Creates a font face object. 4832 /// </summary> 4833 /// <param name="fontFaceType">The file format of the font face.</param> 4834 /// <param name="numberOfFiles">The number of font files required to represent the font face.</param> 4835 /// <param name="fontFiles">Font files representing the font face. Since IDWriteFontFace maintains its own references 4836 /// to the input font file objects, it's OK to release them after this call.</param> 4837 /// <param name="faceIndex">The zero based index of a font face in cases when the font files contain a collection of font faces. 4838 /// If the font files contain a single face, this value should be zero.</param> 4839 /// <param name="fontFaceSimulationFlags">Font face simulation flags for algorithmic emboldening and italicization.</param> 4840 /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param> 4841 /// <returns> 4842 /// Standard HRESULT error code. 4843 /// </returns> 4844 HRESULT CreateFontFace( 4845 DWRITE_FONT_FACE_TYPE fontFaceType, 4846 UINT32 numberOfFiles, 4847 const(IDWriteFontFile)* fontFiles, 4848 UINT32 faceIndex, 4849 DWRITE_FONT_SIMULATIONS fontFaceSimulationFlags, 4850 /*out*/ IDWriteFontFace* fontFace 4851 ); 4852 4853 /// <summary> 4854 /// Creates a rendering parameters object with default settings for the primary monitor. 4855 /// </summary> 4856 /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param> 4857 /// <returns> 4858 /// Standard HRESULT error code. 4859 /// </returns> 4860 HRESULT CreateRenderingParams( 4861 /*out*/ IDWriteRenderingParams* renderingParams 4862 ); 4863 4864 /// <summary> 4865 /// Creates a rendering parameters object with default settings for the specified monitor. 4866 /// </summary> 4867 /// <param name="monitor">The monitor to read the default values from.</param> 4868 /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param> 4869 /// <returns> 4870 /// Standard HRESULT error code. 4871 /// </returns> 4872 HRESULT CreateMonitorRenderingParams( 4873 HMONITOR monitor, 4874 /*out*/ IDWriteRenderingParams* renderingParams 4875 ); 4876 4877 /// <summary> 4878 /// Creates a rendering parameters object with the specified properties. 4879 /// </summary> 4880 /// <param name="gamma">The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.</param> 4881 /// <param name="enhancedContrast">The amount of contrast enhancement, zero or greater.</param> 4882 /// <param name="clearTypeLevel">The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).</param> 4883 /// <param name="pixelGeometry">The geometry of a device pixel.</param> 4884 /// <param name="renderingMode">Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.</param> 4885 /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param> 4886 /// <returns> 4887 /// Standard HRESULT error code. 4888 /// </returns> 4889 HRESULT CreateCustomRenderingParams( 4890 FLOAT gamma, 4891 FLOAT enhancedContrast, 4892 FLOAT clearTypeLevel, 4893 DWRITE_PIXEL_GEOMETRY pixelGeometry, 4894 DWRITE_RENDERING_MODE renderingMode, 4895 /*out*/ IDWriteRenderingParams* renderingParams 4896 ); 4897 4898 /// <summary> 4899 /// Registers a font file loader with DirectWrite. 4900 /// </summary> 4901 /// <param name="fontFileLoader">Pointer to the implementation of the IDWriteFontFileLoader for a particular file resource type.</param> 4902 /// <returns> 4903 /// Standard HRESULT error code. 4904 /// </returns> 4905 /// <remarks> 4906 /// This function registers a font file loader with DirectWrite. 4907 /// Font file loader interface handles loading font file resources of a particular type from a key. 4908 /// The font file loader interface is recommended to be implemented by a singleton object. 4909 /// A given instance can only be registered once. 4910 /// Succeeding attempts will return an error that it has already been registered. 4911 /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite 4912 /// inside their constructors and must not unregister themselves in their destructors, because 4913 /// registration and unregistration operations increment and decrement the object reference count respectively. 4914 /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed 4915 /// outside of the font file loader implementation as a separate step. 4916 /// </remarks> 4917 HRESULT RegisterFontFileLoader( 4918 IDWriteFontFileLoader fontFileLoader 4919 ); 4920 4921 /// <summary> 4922 /// Unregisters a font file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader. 4923 /// </summary> 4924 /// <param name="fontFileLoader">Pointer to the file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader.</param> 4925 /// <returns> 4926 /// This function will succeed if the user loader is requested to be removed. 4927 /// It will fail if the pointer to the file loader identifies a standard DirectWrite loader, 4928 /// or a loader that is never registered or has already been unregistered. 4929 /// </returns> 4930 /// <remarks> 4931 /// This function unregisters font file loader callbacks with the DirectWrite font system. 4932 /// The font file loader interface is recommended to be implemented by a singleton object. 4933 /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite 4934 /// inside their constructors and must not unregister themselves in their destructors, because 4935 /// registration and unregistration operations increment and decrement the object reference count respectively. 4936 /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed 4937 /// outside of the font file loader implementation as a separate step. 4938 /// </remarks> 4939 HRESULT UnregisterFontFileLoader( 4940 IDWriteFontFileLoader fontFileLoader 4941 ); 4942 4943 /// <summary> 4944 /// Create a text format object used for text layout. 4945 /// </summary> 4946 /// <param name="fontFamilyName">Name of the font family</param> 4947 /// <param name="fontCollection">Font collection. NULL indicates the system font collection.</param> 4948 /// <param name="fontWeight">Font weight</param> 4949 /// <param name="fontStyle">Font style</param> 4950 /// <param name="fontStretch">Font stretch</param> 4951 /// <param name="fontSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param> 4952 /// <param name="localeName">Locale name</param> 4953 /// <param name="textFormat">Contains newly created text format object, or NULL in case of failure.</param> 4954 /// <returns> 4955 /// Standard HRESULT error code. 4956 /// </returns> 4957 HRESULT CreateTextFormat( 4958 const(WCHAR)* fontFamilyName, 4959 IDWriteFontCollection fontCollection, 4960 DWRITE_FONT_WEIGHT fontWeight, 4961 DWRITE_FONT_STYLE fontStyle, 4962 DWRITE_FONT_STRETCH fontStretch, 4963 FLOAT fontSize, 4964 const(WCHAR)* localeName, 4965 /*out*/ IDWriteTextFormat* textFormat 4966 ); 4967 4968 /// <summary> 4969 /// Create a typography object used in conjunction with text format for text layout. 4970 /// </summary> 4971 /// <param name="typography">Contains newly created typography object, or NULL in case of failure.</param> 4972 /// <returns> 4973 /// Standard HRESULT error code. 4974 /// </returns> 4975 HRESULT CreateTypography( 4976 /*out*/ IDWriteTypography* typography 4977 ); 4978 4979 /// <summary> 4980 /// Create an object used for interoperability with GDI. 4981 /// </summary> 4982 /// <param name="gdiInterop">Receives the GDI interop object if successful, or NULL in case of failure.</param> 4983 /// <returns> 4984 /// Standard HRESULT error code. 4985 /// </returns> 4986 HRESULT GetGdiInterop( 4987 /*out*/ IDWriteGdiInterop* gdiInterop 4988 ); 4989 4990 /// <summary> 4991 /// CreateTextLayout takes a string, format, and associated constraints 4992 /// and produces an object representing the fully analyzed 4993 /// and formatted result. 4994 /// </summary> 4995 /// <param name="string">The string to layout.</param> 4996 /// <param name="stringLength">The length of the string.</param> 4997 /// <param name="textFormat">The format to apply to the string.</param> 4998 /// <param name="maxWidth">Width of the layout box.</param> 4999 /// <param name="maxHeight">Height of the layout box.</param> 5000 /// <param name="textLayout">The resultant object.</param> 5001 /// <returns> 5002 /// Standard HRESULT error code. 5003 /// </returns> 5004 HRESULT CreateTextLayout( 5005 const(WCHAR)* string, 5006 UINT32 stringLength, 5007 IDWriteTextFormat textFormat, 5008 FLOAT maxWidth, 5009 FLOAT maxHeight, 5010 /*out*/ IDWriteTextLayout* textLayout 5011 ); 5012 5013 /// <summary> 5014 /// CreateGdiCompatibleTextLayout takes a string, format, and associated constraints 5015 /// and produces and object representing the result formatted for a particular display resolution 5016 /// and measuring mode. The resulting text layout should only be used for the intended resolution, 5017 /// and for cases where text scalability is desired, CreateTextLayout should be used instead. 5018 /// </summary> 5019 /// <param name="string">The string to layout.</param> 5020 /// <param name="stringLength">The length of the string.</param> 5021 /// <param name="textFormat">The format to apply to the string.</param> 5022 /// <param name="layoutWidth">Width of the layout box.</param> 5023 /// <param name="layoutHeight">Height of the layout box.</param> 5024 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI device then pixelsPerDip 5025 /// is 1. If rendering onto a 120 DPI device then pixelsPerDip is 120/96.</param> 5026 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 5027 /// scaling specified the font size and pixelsPerDip.</param> 5028 /// <param name="useGdiNatural"> 5029 /// When set to FALSE, instructs the text layout to use the same metrics as GDI aliased text. 5030 /// When set to TRUE, instructs the text layout to use the same metrics as text measured by GDI using a font 5031 /// created with CLEARTYPE_NATURAL_QUALITY. 5032 /// </param> 5033 /// <param name="textLayout">The resultant object.</param> 5034 /// <returns> 5035 /// Standard HRESULT error code. 5036 /// </returns> 5037 HRESULT CreateGdiCompatibleTextLayout( 5038 const(WCHAR)* string, 5039 UINT32 stringLength, 5040 IDWriteTextFormat textFormat, 5041 FLOAT layoutWidth, 5042 FLOAT layoutHeight, 5043 FLOAT pixelsPerDip, 5044 const(DWRITE_MATRIX)* transform, 5045 BOOL useGdiNatural, 5046 /*out*/ IDWriteTextLayout* textLayout 5047 ); 5048 5049 /// <summary> 5050 /// The application may call this function to create an inline object for trimming, using an ellipsis as the omission sign. 5051 /// The ellipsis will be created using the current settings of the format, including base font, style, and any effects. 5052 /// Alternate omission signs can be created by the application by implementing IDWriteInlineObject. 5053 /// </summary> 5054 /// <param name="textFormat">Text format used as a template for the omission sign.</param> 5055 /// <param name="trimmingSign">Created omission sign.</param> 5056 /// <returns> 5057 /// Standard HRESULT error code. 5058 /// </returns> 5059 HRESULT CreateEllipsisTrimmingSign( 5060 IDWriteTextFormat textFormat, 5061 /*out*/ IDWriteInlineObject* trimmingSign 5062 ); 5063 5064 /// <summary> 5065 /// Return an interface to perform text analysis with. 5066 /// </summary> 5067 /// <param name="textAnalyzer">The resultant object.</param> 5068 /// <returns> 5069 /// Standard HRESULT error code. 5070 /// </returns> 5071 HRESULT CreateTextAnalyzer( 5072 /*out*/ IDWriteTextAnalyzer* textAnalyzer 5073 ); 5074 5075 /// <summary> 5076 /// Creates a number substitution object using a locale name, 5077 /// substitution method, and whether to ignore user overrides (uses NLS 5078 /// defaults for the given culture instead). 5079 /// </summary> 5080 /// <param name="substitutionMethod">Method of number substitution to use.</param> 5081 /// <param name="localeName">Which locale to obtain the digits from.</param> 5082 /// <param name="ignoreUserOverride">Ignore the user's settings and use the locale defaults</param> 5083 /// <param name="numberSubstitution">Receives a pointer to the newly created object.</param> 5084 HRESULT CreateNumberSubstitution( 5085 DWRITE_NUMBER_SUBSTITUTION_METHOD substitutionMethod, 5086 const(WCHAR)* localeName, 5087 BOOL ignoreUserOverride, 5088 /*out*/ IDWriteNumberSubstitution* numberSubstitution 5089 ); 5090 5091 /// <summary> 5092 /// Creates a glyph run analysis object, which encapsulates information 5093 /// used to render a glyph run. 5094 /// </summary> 5095 /// <param name="glyphRun">Structure specifying the properties of the glyph run.</param> 5096 /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI bitmap then pixelsPerDip 5097 /// is 1. If rendering onto a 120 DPI bitmap then pixelsPerDip is 120/96.</param> 5098 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 5099 /// scaling specified the emSize and pixelsPerDip.</param> 5100 /// <param name="renderingMode">Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default 5101 /// and not outline).</param> 5102 /// <param name="measuringMode">Specifies the method to measure glyphs.</param> 5103 /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs.</param> 5104 /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs.</param> 5105 /// <param name="glyphRunAnalysis">Receives a pointer to the newly created object.</param> 5106 /// <returns> 5107 /// Standard HRESULT error code. 5108 /// </returns> 5109 HRESULT CreateGlyphRunAnalysis( 5110 const(DWRITE_GLYPH_RUN)* glyphRun, 5111 FLOAT pixelsPerDip, 5112 const(DWRITE_MATRIX)* transform, 5113 DWRITE_RENDERING_MODE renderingMode, 5114 DWRITE_MEASURING_MODE measuringMode, 5115 FLOAT baselineOriginX, 5116 FLOAT baselineOriginY, 5117 /*out*/ IDWriteGlyphRunAnalysis* glyphRunAnalysis 5118 ); 5119 5120 } // interface IDWriteFactory 5121 5122 5123 /// <summary> 5124 /// Creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects. 5125 /// </summary> 5126 /// <param name="factoryType">Identifies whether the factory object will be shared or isolated.</param> 5127 /// <param name="iid">Identifies the DirectWrite factory interface, such as __uuidof(IDWriteFactory).</param> 5128 /// <param name="factory">Receives the DirectWrite factory object.</param> 5129 /// <returns> 5130 /// Standard HRESULT error code. 5131 /// </returns> 5132 /// <remarks> 5133 /// Obtains DirectWrite factory object that is used for subsequent creation of individual DirectWrite classes. 5134 /// DirectWrite factory contains internal state such as font loader registration and cached font data. 5135 /// In most cases it is recommended to use the shared factory object, because it allows multiple components 5136 /// that use DirectWrite to share internal DirectWrite state and reduce memory usage. 5137 /// However, there are cases when it is desirable to reduce the impact of a component, 5138 /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it 5139 /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed 5140 /// component. 5141 /// </remarks> 5142 export extern(C) HRESULT DWriteCreateFactory( 5143 DWRITE_FACTORY_TYPE factoryType, 5144 REFIID iid, 5145 /*out*/ IUnknown* factory 5146 ); 5147 5148 // Macros used to define DirectWrite error codes. 5149 enum FACILITY_DWRITE = 0x898; 5150 enum DWRITE_ERR_BASE = 0x5000; 5151 5152 HRESULT MAKE_DWRITE_HR(alias sev, T)(T code) { 5153 return MAKE_HRESULT(sev, FACILITY_DWRITE, DWRITE_ERR_BASE+code); 5154 } 5155 5156 HRESULT MAKE_DWRITE_HR_ERR(T)(T code) { 5157 return MAKE_DWRITE_HR(1, code); 5158 } 5159 5160 5161 // DWrite errors have moved to winerror.h 5162